2010-08-26 172 views
0

我在基于ipad应用程序的分割视图中使用了多个uiviewcontrollers。 有Web服务。对于某些特定的Web服务(例如注销),我需要删除拆分 视图并插入新视图即登录屏幕。但大部分时间都应该LoginRootate方法的Login视图不会被调用导致愚蠢的应用程序不旋转。 背后的原因是什么?我该怎么办?shouldAutoRotate方法无法正常工作..?

回答

0

确保你没有提取您的UIViewController一个UIView其中shouldAutorotateToInterfaceOrientation:函数返回YES,然后添加的UIView到另一个UIView的使用addSubView。我以前遇到过。

+0

其实我通过下面的链接,我发现我在窗口中添加2个视图做错误。即loginview和splitview。现在我已经将loginview作为模态视图解决了我的问题。现在我的应用旋转得很好。 Thakns。 – Mahesh 2010-08-26 13:21:32

0

确保您所有的视图控制器为您的iPad构建返回YESshouldAutorotateToInterfaceOrientation: - 至少那些在那个时候是可见的。

参见:iPad orientation change issue

+0

好的,谢谢它帮助我,我会尝试。 其实在shouldAutorotateToInterfaceOrientation:方法我已经计算viewcontrollers的大小,但在给出不好的尺寸,即它提供prev方向大小,而不是当前。所以我根据尺寸做了一些手动调整。它可能会影响吗? – Mahesh 2010-08-26 08:37:32

1

维护我的遗留代码我加了这个。

- (BOOL)shouldAutorotate{ 
    UIDeviceOrientation orientation = [UIDevice currentDevice].orientation; 
    if (orientation == UIDeviceOrientationUnknown) return YES; 
    BOOL result = [self shouldAutorotateToInterfaceOrientation:orientation]; 
    return result; 
} 

然后原始代码返回有效的自动旋转信息。