强制UIView / UIVIewController方向 [英] Force UIView/UIVIewController orientation

查看:97
本文介绍了强制UIView / UIVIewController方向的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们正在编写一个专门的横向模式的应用程序。我们使用根视图上的变换将其旋转到LandscapeRight,然后由该视图加载的每个视图共享坐标系。这是所有罚款和dandy,除了我们的一个视图有一个UIWebView对象被视图控制器加载。我们试图查看的网站没有填充视图的内容。当我在横向模式下在移动Safari中查看相同的网站时,它看起来是正确的。我的猜测是,我们用于托管WebView的View控制器仍然认为它是纵向模式,因为查询的接口的属性返回1...有一种方法来欺骗视图/视图控制器认为它在特定的方向?

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. That's all fine and dandy, except one of our views has a UIWebView object that's being loaded by a view controller. 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. 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?

推荐答案

希望你已经找到了一个答案,但你可能会试图告诉你的应用程序以横向模式开始,而不是强制它始终旋转到该方向。然后如果你的根视图的shouldAutorotateToInterfaceOrientation只返回yes只有横向模式,我敢打赌你会有你正在寻找的行为。

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.

这个家伙似乎有一个好的教程,如何做到这一切。
http://www.dejoware.com/blogpages/files/iphone_programming_landscape_view_tutorial。 html

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

这篇关于强制UIView / UIVIewController方向的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆