1.AppDelegate.h
@property (assign, nonatomic) BOOL allowRotation;
2.AppDelegate.m
#pragma mark - 自动旋屏相关
-(UIInterfaceOrientationMask)applicaxtion:(UIApplication *)application supportedInterfaceOrientationsForWindow:(UIWindow *)window
{
if (self.allowRotation) {
return UIInterfaceOrientationMaskAll;
}
return UIInterfaceOrientationMaskPortrait;
}
3.viewController.m
#pragma mark - 设置是否自动转屏
- (BOOL)shouldAutorotate
{
return YES;
}