if (interfaceOrientation == UIInterfaceOrientationPortrait) {
return NO;
} else if (interfaceOrientation == UIInterfaceOrientationPortraitUpsideDown) {
return NO;
} else if (interfaceOrientation == UIInterfaceOrientationLandscapeLeft) {
NSLog(@"Landscape left detected!");
return NO;
} else if (interfaceOrientation == UIInterfaceOrientationLandscapeRight) {
NSLog(@"Landscape right detected!");
return YES;
}我正在尝试实现一个只有风景模式的iPad应用程序。我在info.plist中将支持的界面方向设置为横向模式。WHen应用程序启动,视图本身处于横向模式。但是当我在登录后添加了另一个视图,例如Home视图,视图不会旋转为横向视图。这是在肖像模式。在xib文件中,我也将其设置为横向。我已经在登录和主视图控制器中包含了上面的代码。但主视图在登录后不会旋转。
发布于 2011-12-02 18:04:30
在每个视图控制器中执行此操作
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
return (interfaceOrientation == UIInterfaceOrientationLandscapeLeft || interfaceOrientation == UIInterfaceOrientationLandscapeRight)
}发布于 2011-12-02 18:12:58
首先,你不必为每个方向都写检查。只需在视图控制器的shouldAutorotateToInterfaceOrientation方法中使用以下代码即可实现这一点
return (interfaceOrientation == UIInterfaceOrientationLandscapeRight);第二,你能提供更多关于你是如何实际添加更多视图的细节吗?发现问题会更有帮助。
https://stackoverflow.com/questions/8354561
复制相似问题