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; 
这样就可以实现旋转了

你可能感兴趣的:(iOS设置某个界面允许横竖屏切换)