在AppController.mm中添加以下代码:
- (UIInterfaceOrientationMask)application:(UIApplication *)application supportedInterfaceOrientationsForWindow:(nullable UIWindow *)window {
return UIInterfaceOrientationMaskPortrait;
}
这样可以使整个app禁止旋转屏幕。
2.在某个ViewController中添加以下代码:
- (BOOL)shouldAutorotate {
return NO;
}
这样可以对于某个视图实现禁止旋转屏幕的功能。
网友评论