iOS两个强制旋转屏幕的方法
2013-09-11 14:40
453 查看
第一个:
第二个:
非arc:
arc下:
// 状态栏动画持续时间 CGFloat duration = [UIApplication sharedApplication].statusBarOrientationAnimationDuration; [UIView animateWithDuration:duration animations:^{ // 修改状态栏的方向及view的方向进而强制旋转屏幕 [[UIApplication sharedApplication] setStatusBarOrientation:_bottomView.landscapeModel ? UIInterfaceOrientationLandscapeRight : UIInterfaceOrientationPortrait]; self.navigationController.view.transform = _bottomView.landscapeModel ? CGAffineTransformMakeRotation(M_PI_2) : CGAffineTransformIdentity; self.navigationController.view.bounds = CGRectMake(self.navigationController.view.bounds.origin.x, self.navigationController.view.bounds.origin.y, self.view.frame.size.height, self.view.frame.size.width); }];
第二个:
非arc:
if ([[UIDevice currentDevice] respondsToSelector:@selector(setOrientation:)]) { [[UIDevice currentDevice] performSelector:@selector(setOrientation:) withObject:(id)UIInterfaceOrientationLandscapeRight]; }
arc下:
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]; }
相关文章推荐
- iOS两个强制旋转屏幕的方法
- iOS两个强制旋转屏幕的方法
- iOS两个强制旋转屏幕的方法
- iOS两个强制旋转屏幕的方法
- iOS两个强制旋转屏幕的方法
- ios实现屏幕旋转的方法
- iOS - 强制旋转屏幕之代码实现
- ios-旋转屏幕 通用方法
- iOS 上常用的两个功能:点击屏幕和return退出隐藏键盘和解决虚拟键盘挡住UITextField的方法
- 关于IOS屏幕旋转的几个问题1.常规设置2.个别页面强制固定横竖屏
- iOS的push方法推出控制器界面中单个屏幕的旋转问题
- ios(ipad,iphone)屏幕旋转检测通用方法
- IOS Orientation, 想怎么转就怎么转~~~ 此博文主要针对IOS应用, 是屏幕旋转相关问题的一个总结. 主要内容有: IOS5,6,7不同版的适配. 强制旋转和自动旋转.
- 【转】iOS 上常用的两个功能:点击屏幕和return退出隐藏键盘和解决虚拟键盘挡住UITextField的方法
- iOS屏幕旋转,强制横竖屏
- iOS 上常用的两个功能:点击屏幕和return退出隐藏键盘和解决虚拟键盘挡住UITextField的方法
- iOS 上常用的两个功能:点击屏幕和return退出隐藏键盘和解决虚拟键盘挡住UITextField的方法
- iOS 强制旋转屏幕
- iOS 强制旋转屏幕 的代码实现
- iOS 上常用的两个功能:点击屏幕和return退出隐藏键盘和解决虚拟键盘挡住UITextField的方法