強制橫屏
NSNumber *resetOrientationTarget = [NSNumber numberWithInt:UIInterfaceOrientationUnknown];
[[UIDevice currentDevice] setValue:resetOrientationTarget forKey:@"orientation"];
NSNumber *orientationTarget = [NSNumber numberWithInt:UIInterfaceOrientationPortrait];
[[UIDevice currentDevice] setValue:orientationTarget forKey:@"orientation"];
強制豎屏
NSNumber *resetOrientationTarget = [NSNumber numberWithInt:UIInterfaceOrientationUnknown]; [[UIDevice currentDevice] setValue:resetOrientationTarget forKey:@"orientation"];
NSNumber *orientationTarget = [NSNumber numberWithInt:UIInterfaceOrientationLandscapeRight];
[[UIDevice currentDevice] setValue:orientationTarget forKey:@"orientation"];
??
在執(zhí)行上述方法時要重寫controller的一下方法
//1,支持旋轉(zhuǎn)
-(BOOL)shouldAutorotate{
return YES;
}
//2,支持的方向
- (UIInterfaceOrientationMask)supportedInterfaceOrientations {
//所有方向
return UIInterfaceOrientationMaskAllButUpsideDown;
}