iOS固定APP 某个界面强制横屏或者竖屏
2020-01-13 本文已影响0人
New_卡迪熊
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了。