【发布时间】:2011-01-19 18:09:06
【问题描述】:
问题。我的应用程序出现了一个非常奇怪的错误。我有一个 UITabBarController 和几个用于选项卡的视图控制器。在视图控制器中,我通过shouldAutorotateToInterfaceOrientation: 实现了自动旋转,并且在我进行以下更改之前它工作正常。
我在视图控制器中实现了滑动手势以在选项卡之间切换。这是通过以下代码完成的。
- (void)onSwipeLeft {
int _count = [[self.tabBarController.tabBar items] count];
int i = self.view.tag - 1;
if (i < _count - 1) {
self.tabBarController.selectedIndex = (i + 1) % _count;
}
}
onSwipeRight 也是如此。
现在,自动旋转仅在您向左或向右滑动之前有效。之后,shouldAutorotateToInterfaceOrientation: 就再也不会被调用了。
另请参阅。
在this thread 中描述了相同的问题。我有时也看到 类似以下的日志消息:
-[UIWindow beginDisablingInterfaceAutorotation] overflow on <UIWindow: 0x1410e0; frame = (0 0; 320 480); opaque = NO; autoresize = RM+BM; layer = <CALayer: 0x141190>>. Ignoring.我找不到任何其他信息。This question 似乎在描述同样的问题。
This question 似乎描述了一个类似的问题,但使用了
popViewController:。请注意,该错误自 SDK 3.2 以来一直存在。
怎么办?这似乎是 SDK 中的一个错误,在 4.1 中仍然存在。有没有人找到解决方法?这似乎是一种常见的情况。
【问题讨论】:
-
您的 UITabViewController 是否符合自动旋转功能?因为它是其他视图的父视图,所以它也必须允许旋转。
-
我尝试继承 UITabViewController 并在
shouldAutorotateToInterfaceOrientation:中返回YES,但这没有帮助。
标签: iphone ipad ios uitabbarcontroller autorotate