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 ...
随机推荐
- tomcat 会话超时设置
1.为单个WEB设置SESSION 在WEB.XML中添加 xml 代码 <session-config> <session-timeout>15</session-ti ...
- Linux第三方源
由于版权等各方面原因,很多时候在基础安装完Linux后,满多软件并不包含在yum(对于Ubuntu可能是apt-get)源中. 因此可以去下载第三方源,安装下载第三方软件.当然,如果习惯了源代码编译安 ...
- python3 ImageTk 安装方法
使用命令: $ sudo yum search PIL | grep python3 可显示得知: python3-dogpile-cache.noarch : A caching front-end ...
- Google Play和基于Feature的过滤 —— Feature 参考手册
翻译自 Features Reference 下表列出了软/硬件Feature和权限的参考信息,它们被用于GooglePlay. 硬件feature 下面列出了被大多数当前发布的平台所支持的硬件功能描 ...
- Node.Buffer
介绍 Buffer是一个典型的javascript与c++结合的模块,它将性能相关的部分用c++实现,将非性能相关的部分用javascript实现. 纯 JavaScript 对 Unicode 友好 ...
- 基于表单的身份验证(FBA)
https://technet.microsoft.com/zh-cn/library/ee806890(office.15).aspx http://www.tuicool.com/articles ...
- java虚拟机内存溢出各种场景总结
java堆溢出 java堆用于存储对象实例,只要不断地创建对象,并且保证gc roots到对象之间有可达路径来避免垃圾回收机制来清楚这些对象,那么在 对象到达最大堆的容量限制后就会产生内存溢出溢出. ...
- leetcode 211. Add and Search Word - Data structure design Trie树
题目链接 写一个数据结构, 支持两种操作. 加入一个字符串, 查找一个字符串是否存在.查找的时候, '.'可以代表任意一个字符. 显然是Trie树, 添加就是正常的添加, 查找的时候只要dfs查找就可 ...
- IT第六天 - eclipse快捷操作、万年历项目的编写、菱形的打印输出、代码简化
IT第六天 上午 小项目 1.程序提前结束的退出标志 2.登录用户的模拟,给出适当的提示信息 3.根据要求,寻找规律,然后编写程序 Eclipse的使用 1.快捷键的使用 下午 中小项目 1.九九乘法 ...
- uvalive 2322 Wooden Sticks(贪心)
题目连接:2322 Wooden Sticks 题目大意:给出要求切的n个小木棍 , 每个小木棍有长度和重量,因为当要切的长度和重量分别大于前面一个的长度和重量的时候可以不用调整大木棍直接切割, 否则 ...