UITabBarController 内的 UISplitViewController 方向问题

发布于 2024-10-01 04:09:53 字数 732 浏览 0 评论 0原文

背景故事 我知道有很多关于这个主题的主题,但阅读所有主题并不能解决问题。因此,这个“问题”的目的是结合我们所知道的所有信息,以期解决这个问题。

主要问题 当您创建 UISplitViewController 并将其添加到 UITabBarController 时,它将在纵向模式下正常工作(即使您从纵向切换到横向并返回)。然而,如果 iPad 以横向模式启动,一切都会崩溃,无法正确加载视图。

Bug? 在查看 Apple 的文档时,他们有以下说法:

分割视图控制器的视图 应始终以 root 身份安装 您的应用程序窗口的视图。你 永远不应该呈现分割视图 导航或标签栏内部 界面。

因此,对于这是否是一个错误的问题,答案很简单:不,不是。我们正在努力完成一些苹果没有打算完成的事情。就我个人而言,我不知道为什么,因为在纵向模式下启动时它似乎工作正常。

最简单的解决方法 解决此问题的最简单的方法可能是打开 Info.plist 并删除横向模式的所有“支持的界面方向 (iPad)”。它将以纵向模式启动,但会立即切换到横向模式(如果您保持这种方式),并且问题似乎消失了。

现在怎么办? 现在的主要问题是,我们如何才能在横向模式下启动而不会出现问题?请不要链接到框架文件,而是链接到真正的解决方法代码。

Backstory
I know there are a lot of topics about this subject, but reading all of them didn't answer the problem. So the purpose of this 'question' is to combine all that we know to hopefully fix this issue.

Main issue
When you create a UISplitViewController and add it to UITabBarController it will work fine in Portrait mode (even if you swap from portrait to landscape and back). However if the iPad launches in landscape mode all hell breaks loose and no view will load properly.

Bug? When looking at Apple's documentation they had the following to say:

The split view controller’s view
should always be installed as the root
view of your application window. You
should never present a split view
inside of a navigation or tab bar
interface.

So the answer to the question if this is a bug is simple, no it ain't. We are trying to accomplish something that wasn't intended by Apple. Personally I have no idea why because it seems to work fine when launched in portrait mode.

Easiest work around
Probably the easiest work around to this problem is to open the Info.plist and remove all the 'Supported interface orientations (iPad)' for landscape mode. It will launch in portrait mode but will immediately switch to landscape mode (if you hold it that way) and the problems seem to be gone.

Now what?
The main question now is, how can we still launch in landscape mode without the problem? Please no link to framework files but the real work-around code.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

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

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文