1.在AppDelegate.h 里添加标记
2.在AppDelegate.m 里添加这个方法
3.使用
[(AppDelegate*)[UIApplication sharedApplication].delegate setAllowRotation:YES];
来打开屏幕旋转
4.通过使用
[(AppDelegate*)[UIApplication sharedApplication].delegate setAllowRotation:NO];
[[NSNotificationCenter defaultCenter] removeObserver:self];
if ([[UIDevice currentDevice] respondsToSelector:@selector(setOrientation:)]) {
SEL selector = NSSelectorFromString(@”setOrientation:”);
NSInvocation *invocation = [NSInvocation invocationWithMethodSignature:[UIDevice instanceMethodSignatureForSelector:selector]];
[invocation setSelector:selector];
[invocation setTarget:[UIDevice currentDevice]];
int val = UIInterfaceOrientationPortrait;
[invocation setArgument:&val atIndex:2];
[invocation invoke];
}
来取消屏幕旋转