iOS设置某个界面允许横竖屏切换

AppDelegate.h中
@property(nonatomic,assign)NSInteger allowRotation;
AppDelegate.m中
初始化allowRotation
    self.allowRotation = 0;
 
- (NSUInteger)application:(UIApplication *)application supportedInterfaceOrientationsForWindow:(UIWindow *)window
{
    if (_allowRotation == 1) {
        return UIInterfaceOrientationMaskAllButUpsideDown;//这个可以根据自己的需求设置旋转方向
    }
    else
    {
        return (UIInterfaceOrientationMaskPortrait);
    }
} 
这样设置之后,在想要支持横竖屏切换的界面设置 
#import "AppDelegate.h"
  AppDelegate *appDelegate = (AppDelegate *)[UIApplication sharedApplication].delegate;
  appDelegate.allowRotation = 1; 
这样就可以实现旋转了

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容