iOS8的屏幕旋转的问题
判断横竖屏。http://www.cocoachina.com/ask/questions/show/121301
//self.cameraView是相机view - (NSUInteger)supportedInterfaceOrientations { UIInterfaceOrientation e = [[UIApplication sharedApplication] statusBarOrientation]; if (e == UIInterfaceOrientationLandscapeLeft) { if (self.cameraView) { self.cameraView.transform = CGAffineTransformMakeRotation((- * M_PI) / 180.0f); } }else if (e == UIInterfaceOrientationLandscapeRight) { if (self.cameraView) { self.cameraView.transform = CGAffineTransformMakeRotation(( * M_PI) / 180.0f); } } return (UIInterfaceOrientationMaskLandscape); } - (void)viewDidLoad { [super viewDidLoad]; // Do any additional setup after loading the view. //m_bScreen是bool 型,判断横竖屏。 if ([[[UIDevice currentDevice]systemVersion ]floatValue] >= 8.0) { BOOL m_bScreen = NO; UIInterfaceOrientation e = [[UIApplication sharedApplication] statusBarOrientation]; if (e == UIInterfaceOrientationLandscapeLeft) { m_bScreen = NO; }else if (e == UIInterfaceOrientationLandscapeRight) { m_bScreen = YES; } if ([[UIDevice currentDevice] respondsToSelector:@selector(setOrientation:)]) { NSNumber *num = [[NSNumber alloc] initWithInt:(m_bScreen?UIInterfaceOrientationLandscapeRight:UIInterfaceOrientationLandscapeLeft)]; [[UIDevice currentDevice] performSelector:@selector(setOrientation:) withObject:(id)num]; [UIViewController attemptRotationToDeviceOrientation];//这行代码是关键 } SEL selector=NSSelectorFromString(@"setOrientation:"); NSInvocation *invocation =[NSInvocation invocationWithMethodSignature:[UIDevice instanceMethodSignatureForSelector:selector]]; [invocation setSelector:selector]; [invocation setTarget:[UIDevice currentDevice]]; int val =m_bScreen?UIInterfaceOrientationLandscapeRight:UIInterfaceOrientationLandscapeLeft; [invocation setArgument:&val atIndex:]; [invocation invoke]; } }
获取相机view的方法:
#pragma mark UINavigationControllerDelegate - (void)navigationController:(UINavigationController *)navigationController willShowViewController:(UIViewController *)viewController animated:(BOOL)animated{ if ([[[UIDevice currentDevice]systemVersion ]floatValue] >= 8.0) { UIView *PLCameraView=[self findView:viewController.view withName:@"PLImagePickerCameraView"]; NSArray *svarray = [PLCameraView subviews]; self.imagePickerController.cameraView = svarray[0]; for (int i = ; i < svarray.count; i++) { //i: 0 相机 1 拍照界面 2 重拍界面 if (i == ) { NSArray *arr = [svarray[] subviews]; for (int i = ; i < arr.count; i++) { if (i == ) { //i: 1 前置摄像头切换 [[arr objectAtIndex:i] setAlpha:0.0f]; } } } } }else if ([[[UIDevice currentDevice]systemVersion ]floatValue] >= 7.0) { UIView *PLCameraView=[self findView:viewController.view withName:@"PLCameraView"]; NSArray *svarray = [PLCameraView subviews]; for (int i = ; i < svarray.count; i++) { //i: 0 相机 1 拍照界面 2 重拍界面 if (i == ) { NSArray *arr = [svarray[] subviews]; for (int i = ; i < arr.count; i++) { if (i == ) { //i: 1 前置摄像头切换 [[arr objectAtIndex:i] setAlpha:0.0f]; } } } } } } #pragma mark get/show the UIView we want //Find the view we want in camera structure. -(UIView *)findView:(UIView *)aView withName:(NSString *)name{ Class cl = [aView class]; NSString *desc = [cl description]; if ([name isEqualToString:desc]) return aView; for (NSUInteger i = ; i < [aView.subviews count]; i++) { UIView *subView = [aView.subviews objectAtIndex:i]; subView = [self findView:subView withName:name]; if (subView) return subView; } return nil; }
iOS8的屏幕旋转的问题的更多相关文章
- ios实现屏幕旋转的方法
1.屏蔽AppDelegate下面的屏幕旋转方法 #pragma mark - 屏幕旋转的 //- (UIInterfaceOrientationMask)application:(UIApplica ...
- iOS屏幕旋转 浅析
一.两种orientation 了解屏幕旋转首先需要区分两种orientation 1.device orientation 设备的物理方向,由类型UIDeviceOrientation表示,当前设备 ...
- UI基础:视图控制器.屏幕旋转.MVC 分类: iOS学习-UI 2015-07-02 22:21 62人阅读 评论(0) 收藏
UIViewController 视图控制器,继承自UIResponder,作用:管理视图并且响应事件 功能: 1.分担APPdelegate的工作 2.实现模块独立,能提高复用性 创建UIViewC ...
- Runtime解决屏幕旋转问题
前言 大家或许在iOS程序开发中经常遇到屏幕旋转问题,比如说希望指定的页面进行不同的屏幕旋转,但由于系统提供的方法是导航控制器的全局方法,无法随意的达到这种需求.一般的解决方案是继承UINavrgat ...
- 【Android】[转] Android屏幕旋转使用OrientationEventListener的监听
说明 遇到一个奇葩的问题,我在使用onConfigChanged拦截屏幕的横竖屏旋转时,发现直接进行180度的横屏/竖屏转换居然没有反应!查找原因发现仅对landscape或者portrait状态有用 ...
- Android 屏幕旋转 处理 AsyncTask 和 ProgressDialog 的最佳方案
的最佳方案 标签: Android屏幕旋转AsyncTaskProgressDialog 2014-07-19 09:25 39227人阅读 评论(46) 收藏 举报 分类: [android 进阶之 ...
- iOS实现屏幕旋转
iOS实现屏幕旋转有两种方式 1. 应用本身支持 2. 手动旋转UIView (这种方式我没找到旋转 系统控件的方法 如:键盘.导航.UIAlertView) 如果你只是要把竖屏的播放器,做成支持横屏 ...
- Recovery和Charger模式下屏幕旋转180度
转自:http://www.etwiki.cn/android/1267.html 如何让Recovery (系统固件升级),charger(关机充电动画)时屏幕旋转180度 解决方法: 1.在boo ...
- View页面内容的旋转,在某些情况下可替代屏幕旋转使用
这个是在做小秘书的体重曲线图的时候用到的,横排的时候可以多显示些内容,可是由于很多未知的冲突导至屏幕旋转起来非常麻烦,可用用旋转页面的内容来达到旋转屏幕的效果. 代码如下: //旋转90度 CGAff ...
随机推荐
- javascript学习笔记(window .alert 是什么)
<script language="javascript"> var abc="25"; window .alert(abc); </scri ...
- 射频识别技术漫谈(13)——Mifare S50与Mifare S70
Mifare S50和Mifare S70又常被称为Mifare Standard.Mifare Classic.MF1,是遵守ISO14443A标准的卡片中应用最为广泛.影响力最大的的一员.而Mif ...
- Protel 99SE铺铜问题总结
一.PCB电路板放置铺铜有什么作用? 散热: 屏蔽 抗干扰 pcb板子带有寄生电容: 提高板子强度: 美观: 增加被抄板的难度,尤其是覆铜+黑油. 二.PROTEL不规则铺铜的方法: 1.先要知道 ...
- 在OSX狮子(Lion)上安装MYSQL(Install MySQL on Mac OSX)
这篇文章简述了在Mac OSX狮子(Lion)上安装MySQL Community Server最新版本v10.6.7的过程. MySQL是最流行的开源数据库管理系统.首先,从MySQL的下载页面上下 ...
- Mysql-udf-http 插件的安装与使用
1. 在Linux系统上安装Mysql-udf-http ulimit -SHn wget http://curl.haxx.se/download/curl-7.21.1.tar.gz .tar ...
- nodejs--express开发个人博客(2)
上一部分已经实现了视图的雏形,现在加上逻辑操作. 登陆.注册.文章发表都需要用到数据库的数据存取,用的比较多的就是mongodb了. MongoDB 是一个对象数据库,它没有表.行等概念,也没有固定的 ...
- Java多线程之synchronized(一)
在上节中已经说过了“非线程安全”是如何出现的,链接如下:http://www.cnblogs.com/chentong/p/5650137.html,那么怎么解决“非线程安全”问题呢,只需要在两个线程 ...
- C++改变编程入口为main函数
1, 你用vc建了一个控制台程序,它的入口函数应该是main, 而你使用了WinMain. 2. 你用vc打开了一个.c/.cpp 文件,然后直接编译这个文件,这个文件中使用了WinMian而不是m ...
- Binary Tree Preorder Traversal and Binary Tree Postorder Traversal
Binary Tree Preorder Traversal Given a binary tree, return the preorder traversal of its nodes' valu ...
- JDBC----数据库连接池(connection pool)
•数据库连接池的基本思想就是为数据库连接建立一个"缓冲池".预先在缓冲池中放入一定数量的连接,当需要建立数据库连接时,只需从"缓冲池"中取出一个,使用完毕之后再 ...