简体   繁体   English

强制UIView / UIVIewController方向

[英]Force UIView/UIVIewController orientation

We're writing an application that's in landscape mode exclusively. 我们正在编写一个专门用于横向模式的应用程序。 We use a transform on a root view to rotate it to LandscapeRight, then every view that gets loaded by that view shares the coordinate system. 我们在根视图上使用变换将其旋转到LandscapeRight,然后由该视图加载的每个视图共享坐标系。 That's all fine and dandy, except one of our views has a UIWebView object that's being loaded by a view controller. 除了我们的一个视图有一个由视图控制器加载的UIWebView对象外,这一切都很好。 The site that we're trying to look at doesn't have its content filling the view. 我们试图查看的网站没有内容填充视图。 When I view the same site in mobile Safari in landscape mode, it looks correct. 当我在横向模式下在移动Safari中查看同一站点时,它看起来是正确的。 My guess is that the View Controller we're using to host the WebView still thinks it's in portrait mode, as querying the interfaceOrientation of the property returns "1"...is there a way to trick a view/view controller to think it's in a specific orientation? 我的猜测是我们用来托管WebView的View Controller仍然认为它处于纵向模式,因为查询属性的interfaceOrientation会返回“1”...是否有办法诱骗视图/视图控制器认为它是在特定的方向?

Hopefully you've already found an answer for this, but you might try telling your app to just start out in landscape mode, rather than forcing it to always rotate to that orientation. 希望您已经找到了答案,但您可能会尝试告诉您的应用程序刚开始横向模式,而不是强迫它始终旋转到该方向。 Then if your root view's shouldAutorotateToInterfaceOrientation returns yes only for landscape modes, I'd bet you'd have the behavior you're looking for. 然后,如果您的根视图的shouldAutorotateToInterfaceOrientation仅为横向模式返回yes,我敢打赌您将拥有您正在寻找的行为。

This guy seems to have a good tutorial about how to do all that. 这家伙似乎有一个关于如何做到这一切的好教程。 http://www.dejoware.com/blogpages/files/iphone_programming_landscape_view_tutorial.html http://www.dejoware.com/blogpages/files/iphone_programming_landscape_view_tutorial.html

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM