#import "AppDelegate.h"
@property (nonatomic,assign)BOOL allowAcrolls;
添加一下方法
- (UIInterfaceOrientationMask)application:(UIApplication *)applicationsupportedInterfaceOrientationsForWindow:(UIWindow *)window {
if(self.allowAcrolls) {
returnUIInterfaceOrientationMaskLandscapeLeft;
}
returnUIInterfaceOrientationMaskPortrait;
}
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了。
网友评论