81.一个界面支持横屏,其他界面不支持

2018-05-10  本文已影响0人  rebeccaBull
在AppDelegate中,添加如下字段
@property (nonatomic)short allowRotation;//是否支持旋转 在需要旋转的VC viewdidload 方法设置此字段为1, 将要消失的时候设置为0 并设置支持方向

/**
 设备的支持方向
 */
- (UIInterfaceOrientationMask)application:(UIApplication *)application supportedInterfaceOrientationsForWindow:(UIWindow *)window{
    if (_allowRotation == 1) {
        return UIInterfaceOrientationMaskLandscapeLeft;
    }else{
        return UIInterfaceOrientationMaskPortrait;
    }
}
/**
 设置设备是否可以旋转
 */
- (BOOL)shouldAutorotate{
    if (_allowRotation == 1) {
        return YES;
    }else{
        return NO;
    }
}


在使用的VC里,设置此字段为1
在该VC离开的时候,设置此字段为0
上一篇 下一篇

猜你喜欢

热点阅读