iOS强制屏幕旋转

/**

强制旋转屏幕为纵向 (注:这种方式 键盘不能旋转过来; iOS8.x下 UIAlterView旋转不过来  )

@return

*/

+ (void)rotateOrientationPortrait{

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];

}

}

/**

强制旋转屏幕为横向,Home建向右 (注:这种方式 键盘不能旋转过来; iOS8.x下 UIAlterView旋转不过来  )

@return

*/

+ (void)rotateOrientationLandscapeRight{

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 = UIInterfaceOrientationLandscapeRight;

[invocation setArgument:&val atIndex:2];

[invocation invoke];

}

}

上一篇:C#开发BIMFACE系列8 服务端API之获取文件上传状态信息


下一篇:uva 825 - Walking on the Safe Side(dp)