iOS开发中禁止屏幕旋转的2种方式

来源:互联网 发布:矩阵lu分解问题 编辑:程序博客网 时间:2024/06/06 05:36
  1. 在AppDelegate.m中添加以下代码:
- (UIInterfaceOrientationMask)application:(UIApplication *)application supportedInterfaceOrientationsForWindow:(nullable UIWindow *)window {    return UIInterfaceOrientationMaskPortrait;}

这样可以使整个app禁止旋转屏幕。

2.在某个ViewController中添加以下代码:

- (BOOL)shouldAutorotate {    return NO;}

这样可以对于某个视图实现禁止旋转屏幕的功能。

0 0
原创粉丝点击