1.在AppDelegate.h 裏添加標記spa
2.在AppDelegate.m 裏添加這個方法3d
3.打開屏幕旋轉server
[(AppDelegate*)[UIApplication sharedApplication].delegate setAllowRotation:YES];blog
4.取消屏幕旋轉rem
[(AppDelegate*)[UIApplication sharedApplication].delegate setAllowRotation:NO];get
[[NSNotificationCenter defaultCenter] removeObserver:self];it
if ([[UIDevice currentDevice] respondsToSelector:@selector(setOrientation:)]) {io
SEL selector = NSSelectorFromString(@"setOrientation:");class
NSInvocation *invocation = [NSInvocation invocationWithMethodSignature:[UIDeviceinstanceMethodSignatureForSelector:selector]];select
[invocation setSelector:selector];
[invocation setTarget:[UIDevice currentDevice]];
int val = UIInterfaceOrientationPortrait;
[invocation setArgument:&val atIndex:2];
[invocation invoke];
}