//强制旋转屏幕
- (void)orientationToPortrait:(UIInterfaceOrientation)orientation {
SEL selector = NSSelectorFromString(@"setOrientation:");
NSInvocation *invocation = [NSInvocation invocationWithMethodSignature:[UIDevice instanceMethodSignatureForSelector:selector]];
[invocation setSelector:selector];
[invocation setTarget:[UIDevice currentDevice]];
int val = orientation;
[invocation setArgument:&val atIndex:2];//前两个参数已被target和selector占用
[invocation invoke];
}
参数 说明:
UIInterfaceOrientationPortrait = 设备定位肖像 (正向)
UIInterfaceOrientationPortraitUpsideDown = 设备方向颠倒画像 (竖屏,倒立)
UIInterfaceOrientationLandscapeLeft = 设备朝向左横向 (横屏 朝左)
UIInterfaceOrientationLandscapeRight = 设备朝向右横向 (横屏 朝右)