奇怪的景观 UITabBarController 应用程序启动
我的应用程序非常简单,但是启动时遇到一些问题。 我在Info.plist中设置为景观,但它似乎忽略了顺序。 事实上,当应用程序加载时,模拟器是横向的,但随后它会以纵向模式返回。
这是视图和控制器的层次结构:
- MainViewController(扩展 UITabBarController 只是为了覆盖 shouldAutorotateToInterfaceOrientation:)
- 三个扩展的 UITableViewController 作为选项卡(也正确设置了 shouldAutorotateToInterfaceOrientation)。
如果我有点强制设备的方向为横向:
[[UIDevice currentDevice] setOrientation: UIInterfaceOrientationLandscapeRight];
然后模拟器瞬间以纵向模式闪烁,然后变成横向模式。 问题是,这样,自动旋转动画就开始了,这是我无法忍受的。 我只想要一个固定的、景观化的应用程序。
有什么线索吗? 我错过了什么吗?
My application is quite simple, but I have some problems when it starts. I setted in the Info.plist to be landscaped, but it seems to ignore the order. In fact, when the app is loading the Simulator is landscaped, but then it returns in portrait mode.
This is the hierarchy of the views and controllers:
- MainViewController (extends UITabBarController just to override shouldAutorotateToInterfaceOrientation:)
- Three extended UITableViewControllers as tabs (also those have the shouldAutorotateToInterfaceOrientation correctly setted up).
If I kinda force the orientation of the device to Landscape with:
[[UIDevice currentDevice] setOrientation: UIInterfaceOrientationLandscapeRight];
Then for an instant the Simulator flashes in portrait mode, and then it goes landscaped. The problem is that in this way, the auto-rotation animations gets started, which is something I cannot tollerate. I just want a fixed, landscaped application.
Any clues? Am I missing something?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
尝试以下操作。 不知道为什么它对你不起作用
1)设置键 UIInterfaceOrientation
到 .plist 文件中的 UIInterfaceOrientationLandscapeRight
2) 重写 UITabBarController shouldAutorotateToInterfaceOrientation() 方法; 下面的代码仅处理选项卡零和选项卡一,并且仅处理一个控制器:如果您有一个导航控制器并且想要控制堆栈上的不同控制器,则必须相应地修改代码
2)
设置您的委托的 applicationDidFinishLaunching() 方法仅在模拟器上需要,而不是在设备上
3) 在控制器中添加以下 shouldAutorotateToInterfaceOrientation(method)
4) 在您的设备上运行应用程序,并使用“硬件”菜单项“旋转”验证其是否正常工作向左和向右旋转。 您应该看到横向模式下的显示。
Try the following. Not sure why it does not work for you
1) set the key UIInterfaceOrientation
to UIInterfaceOrientationLandscapeRight in your .plist file
2) override your UITabBarController shouldAutorotateToInterfaceOrientation() method; in the following the code only deals with tab zero and one, and only with one controller: if you have a navigation controller and you want to control different controllers that may be on the stack, you have to modify the code accordingly
2) setting
in your delegate's applicationDidFinishLaunching() method is only required for the simulator, not on a device
3) add the following shouldAutorotateToInterfaceOrientation(method) in your controllers
4) run the app on your device and verify that it works properly by using the Hardware menu item Rotate Left and Rotate Right. You should see the display in landscape-mode.
也许这可以帮助
http://www.dejoware.com/blogpages/files/iphone_programming_landscape_view_tutorial.html
maybe this can help
http://www.dejoware.com/blogpages/files/iphone_programming_landscape_view_tutorial.html