IOS 横竖屏

//iOS规定不允许强制用代码切换横竖屏

if([[UIDevicecurrentDevice]respondsToSelector:@selector(setOrientation:)]) {

SELselector =NSSelectorFromString(@"setOrientation:");

NSInvocation*invocation = [NSInvocationinvocationWithMethodSignature:[UIDeviceinstanceMethodSignatureForSelector:selector]];

[invocationsetSelector:selector];

[invocationsetTarget:[UIDevicecurrentDevice]];

intval =UIInterfaceOrientationPortrait;

if(UIDeviceOrientationIsPortrait([UIDevicecurrentDevice].orientation)) {

val =UIInterfaceOrientationLandscapeRight;

}

[invocationsetArgument:&valatIndex:2];

[invocationinvoke];

}

你可能感兴趣的:(IOS 横竖屏)