强制横竖屏间切换
if ([[UIDevice currentDevice] respondsToSelector:@selector(setOrientation:)]) { SEL selector = NSSelectorFromString(@"setOrientation:"); if (UIDeviceOrientationIsLandscape([[UIDevice currentDevice] orientation])) { NSInvocation *invocation = [NSInvocation invocationWithMethodSignature:[UIDevice instanceMethodSignatureForSelector:selector]]; [invocation setSelector:selector]; [invocation setTarget:[UIDevice currentDevice]]; int val = UIInterfaceOrientationPortrait;// [invocation setArgument:&val atIndex:2]; [invocation invoke]; }else{ NSInvocation *invocation = [NSInvocation invocationWithMethodSignature:[UIDevice instanceMethodSignatureForSelector:selector]]; [invocation setSelector:selector]; [invocation setTarget:[UIDevice currentDevice]]; int val = UIInterfaceOrientationLandscapeRight;// [invocation setArgument:&val atIndex:2]; [invocation invoke]; } }
//屏幕旋转 -(BOOL)shouldAutorotate{ return YES; } //支持旋转的方向 //一开始的屏幕旋转方向 //支持旋转的方向 //一开始的屏幕旋转方向 - (NSUInteger)supportedInterfaceOrientations { NSLog(@"11222111111"); return UIInterfaceOrientationLandscapeLeft; } - (UIInterfaceOrientation)preferredInterfaceOrientationForPresentation { return UIInterfaceOrientationLandscapeLeft; }