iPad 中的 UITabBar - 不会进入包含 2 个以上项目的横向模式
我创建了一个新项目并选择了 iPad 的选项卡栏模板。我在 Interface Builder 中打开它,并添加了 4 个项目,使项目总数达到 6 个。我进行了构建并运行,它在 iPad 模拟器中打开得很好,但它无法进入横向模式!然后我在界面生成器中回溯,发现如果选项卡栏中只有 2 个项目,它会横向显示,但如果有更多项目则不会。模拟器会旋转,但所有内容(目前只是苹果放置的占位符)都保持纵向状态。有什么想法吗?
I created a new project and selected the Tab Bar template for iPad. I opened it up in Interface Builder and added 4 more items, bringing the total items to 6. I did a build and run and it opened up fine in the iPad simulator, but it wouldn't go into landscape! I then backtracked in interface builder and found that it would go landscape if there were only 2 items in the tab bar, but not if there were any more. The simulator rotates but all the content (currently just the placeholders put in place by Apple) stays as if it was portrait. Any ideas why?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
UITabBar 中包含的所有视图都必须支持水平视图,容器才能支持它。
来自苹果文档:
当设备方向发生变化时,选项卡栏控制器会查询其视图控制器数组。如果其中任何一个不支持方向,则选项卡栏控制器不会更改其方向。
参考: http://developer.apple.com/library/ios/#featuredarticles/ViewControllerPGforiPhoneOS/TabBarControllers/TabBarControllers.html#//apple_ref/doc/uid/TP40007457-CH102-SW26
所以请确保您的所有视图通过其中的方法来支持水平视图:
All of your views that are included in the UITabBar have to support horizontal view in order for the container to support it.
From the Apple Docs:
When a device orientation change occurs, the tab bar controller queries its array of view controllers. If any one of them does not support the orientation, the tab bar controller does not change its orientation.
Reference: http://developer.apple.com/library/ios/#featuredarticles/ViewControllerPGforiPhoneOS/TabBarControllers/TabBarControllers.html#//apple_ref/doc/uid/TP40007457-CH102-SW26
So make sure all of your views are supporting the horizontal view by having a method like this in them: