我试过了:
- >对UINavigationController进行子类化并覆盖自动旋转方法
- >覆盖MyViewController上的自动旋转方法
- >两者都是。
注意:此外,我尝试使用自动旋转设置NO和YES
这是我的代码:
NavigationControllerNoAutorotate:
@implementation NavigationControllerNoAutorotate
- (UIInterfaceOrientationMask)supportedInterfaceOrientations {
return UIInterfaceOrientationPortrait;
}
- (BOOL)shouldAutorotate {
return YES;
}
@end
MyViewController:
- (BOOL)shouldAutorotate {
return NO;
}
- (UIInterfaceOrientationMask)supportedInterfaceOrientations {
return UIInterfaceOrientationMaskPortrait;
}
- (UIInterfaceOrientationMask)navigationControllerSupportedInterfaceOrientations:(UINavigationController *)navigationController {
return UIInterfaceOrientationPortrait;
}