【发布时间】:2012-10-03 17:47:06
【问题描述】:
我的大部分应用程序不支持轮换。在支持的方向上,我只选择了肖像。在应用程序使用的 UIViewController 子类上,我有这个:
-(BOOL)shouldAutorotate {
return NO;
}
-(NSUInteger)supportedInterfaceOrientations {
NSLog(@"supported?");
return UIInterfaceOrientationMaskPortrait;
}
-(UIInterfaceOrientation)preferredInterfaceOrientationForPresentation {
NSLog(@"preferred");
return UIInterfaceOrientationPortrait;
}
在支持方向的 UIViewController 子类中,我有这个:
-(BOOL)shouldAutorotate {
return YES;
}
-(NSUInteger)supportedInterfaceOrientations {
NSLog(@"supported?");
return UIInterfaceOrientationMaskAll;
}
-(UIInterfaceOrientation)preferredInterfaceOrientationForPresentation {
NSLog(@"preferred");
return UIInterfaceOrientationPortrait;
}
但是,我的应用程序不会在任何视图上旋转,包括这个。怎样才能让它按我的意愿在这里旋转?
【问题讨论】:
-
您是否将所有方向添加到 Info.plist 中支持的方向?
-
不,我只选择了肖像作为支持的方向。如果我启用横向,它只会在每个视图控制器上旋转到横向。
-
你有导航控制器吗?
-
你应该支持你的应用程序使用的所有方向。所以问题应该是为什么你的视图控制器旋转到横向。
-
@rooster117 是的。 DrummerB - 好的,所以如果它设置为打开,我如何阻止它在某些视图上旋转到横向?
标签: iphone objective-c ios xcode rotation