//強(qiáng)制旋轉(zhuǎn)屏幕
- (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];//前兩個參數(shù)已被target和selector占用
[invocation invoke];
}
參數(shù) 說明:
UIInterfaceOrientationPortrait = 設(shè)備定位肖像 (正向)
UIInterfaceOrientationPortraitUpsideDown = 設(shè)備方向顛倒畫像 (豎屏合陵,倒立)
UIInterfaceOrientationLandscapeLeft = 設(shè)備朝向左橫向 (橫屏 朝左)
UIInterfaceOrientationLandscapeRight = 設(shè)備朝向右橫向 (橫屏 朝右)