iPad 中的 UITabBar - 不会进入包含 2 个以上项目的横向模式

发布于 2024-08-31 01:09:37 字数 213 浏览 11 评论 0原文

我创建了一个新项目并选择了 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

追我者格杀勿论 2024-09-07 01:09:37

UITabBar 中包含的所有视图都必须支持水平视图,容器才能支持它。

来自苹果文档:
当设备方向发生变化时,选项卡栏控制器会查询其视图控制器数组。如果其中任何一个不支持方向,则选项卡栏控制器不会更改其方向。

参考: http://developer.apple.com/library/ios/#featuredarticles/ViewControllerPGforiPhoneOS/TabBarControllers/TabBarControllers.html#//apple_ref/doc/uid/TP40007457-CH102-SW26

所以请确保您的所有视图通过其中的方法来支持水平视图:

-(BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation{
    return YES;
}

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:

-(BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation{
    return YES;
}
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文