iOS固定APP 某个界面强制横屏或者竖屏

import "AppDelegate.h"

@property (nonatomic,assign)BOOL allowAcrolls;

  • (UIInterfaceOrientationMask)application:(UIApplication *)application supportedInterfaceOrientationsForWindow:(UIWindow *)window {
    if (self.allowAcrolls) {
    return UIInterfaceOrientationMaskLandscapeLeft;
    }
    return UIInterfaceOrientationMaskPortrait;
    }
    2.然后在需要强制转换的方法里添加以下代码:

        AppDelegate *appdelegate = (AppDelegate *)[UIApplication sharedApplication].delegate;
    
         appdelegate.allowAcrolls =YES;
    
        [[UIApplication sharedApplication] setStatusBarHidden:YESwithAnimation:UIStatusBarAnimationNone];
    
         NSNumber *orientationTarget = [NSNumber numberWithInt:UIDeviceOrientationLandscapeRight];
    
         [[UIDevice currentDevice] setValue:orientationTarget forKey:@"orientation"];
    

这样就差不多OK了。

你可能感兴趣的:(iOS固定APP 某个界面强制横屏或者竖屏)