【发布时间】:2010-08-26 08:08:03
【问题描述】:
我在基于拆分视图的 ipad 应用程序中使用了多个 uiviewcontroller。 有网络服务。对于某些特定的 Web 服务(例如注销),我需要删除拆分 查看并插入新视图,即登录屏幕。但大多数时候,登录视图的 shouldAutoRotate 方法不会被调用,从而导致不旋转的愚蠢应用程序。 这背后的原因可能是什么?我该怎么办?
【问题讨论】:
标签: iphone objective-c ipad
我在基于拆分视图的 ipad 应用程序中使用了多个 uiviewcontroller。 有网络服务。对于某些特定的 Web 服务(例如注销),我需要删除拆分 查看并插入新视图,即登录屏幕。但大多数时候,登录视图的 shouldAutoRotate 方法不会被调用,从而导致不旋转的愚蠢应用程序。 这背后的原因可能是什么?我该怎么办?
【问题讨论】:
标签: iphone objective-c ipad
为了维护我的旧代码,我添加了这个。
- (BOOL)shouldAutorotate{
UIDeviceOrientation orientation = [UIDevice currentDevice].orientation;
if (orientation == UIDeviceOrientationUnknown) return YES;
BOOL result = [self shouldAutorotateToInterfaceOrientation:orientation];
return result;
}
那么原代码返回有效的自转信息。
【讨论】:
确保你没有从你的 UIViewController 中提取 UIView,它 shouldAutorotateToInterfaceOrientation: 函数返回 YES,然后使用 addSubView 将 UIView 添加到另一个 UIView。我以前也遇到过。
【讨论】:
确保您的所有视图控制器都为您的 iPad 版本返回 YES 和 shouldAutorotateToInterfaceOrientation: —— 至少是当时可见的那些。
【讨论】: