UITabBar 未正确更新一个视图控制器的方向

发布于 2024-10-02 04:47:27 字数 418 浏览 4 评论 0原文

我有一个 UITabBar,里面有 5 个视图控制器。当选择前四个控制器中的任何一个并且设备方向发生变化时,视图将正确更新。

但是,当最后一个控制器处于活动状态并且设备方向发生变化时,视图的框架不会正确地将其大小更新为新的框架大小,直到我选择另一个选项卡然后返回到第五个选项卡。视图已正确“旋转”,但由于其帧大小不正确而被设备剪裁。

另外,为了在提出问题之前回答问题,我在视图控制器中有以下代码:

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
    // Overriden to allow any orientation.
    return YES;
}

感谢您的帮助!

I have a UITabBar with 5 view controllers in it. When any of the first four controllers are selected and the device orientation changes, the view will correctly update.

However when the last controller is active and the device orientation changes, the frame of the view does not correctly update its size to the new frame size until I select another tab and then go back to the fifth tab. The view is "rotated" correctly, but it is clipped by the device because it has the incorrect frame size.

Also to answer a question before it is asked, I have the following code in the view controller:

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
    // Overriden to allow any orientation.
    return YES;
}

Thanks for any help!

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

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

发布评论

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

评论(1

念﹏祤嫣 2024-10-09 04:47:27

好吧,我不确定这是否是我的代码中的错误或问题,或者一切设置的方式,但我已经弄清楚了。

显然,对于我从添加到此 tabBarController 的 XIB 加载的任何视图,都会发生这种情况。我用其他几个视图进行了测试,只有从 XIB 添加视图时才会发生这种情况。我已经删除了它并从代码构建了所有内容,它现在似乎可以工作了。

Alright well I'm not sure if this is a bug or a problem in my code or the way everything is setup, BUT I've figured it out.

Apparently this happens for any view that I load from an XIB that's added to this tabBarController. I tested out with several other views and it only happened when views were added from XIBs. I've deleted that and built everything from code and it seems to be working now.

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