【发布时间】:2016-10-30 16:40:29
【问题描述】:
我的 UIViewController 没有调用 shouldAutorotate 方法。
尝试了几种方法来强制以纵向模式显示 VC。
示例代码如下:
AppDelegate.m
self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
self.window.backgroundColor = [UIColor whiteColor];
self.navController = [[UINavigationController alloc] initWithRootViewController:[[VCLogin alloc] init]];
[self.window setRootViewController:self.navController];
[UIApplication sharedApplication].statusBarHidden = YES;
[self.window makeKeyAndVisible];
VCLogin.m
- (BOOL)shouldAutorotate
{
return [self.navigationController.visibleViewController shouldAutorotate];
}
- (UIInterfaceOrientationMask)supportedInterfaceOrientations {
return UIInterfaceOrientationMaskPortrait | UIInterfaceOrientationMaskPortrait | UIInterfaceOrientationPortraitUpsideDown;
}
并将设备方向启用为“纵向”、“横向左侧”和“横向右侧”
任何想法将不胜感激。
提前致谢。
【问题讨论】:
-
您需要保护特定的 vc 使其处于纵向模式?
-
是的。我正在使用 iOS 10 sdk
标签: ios objective-c