判断横竖屏。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的屏幕旋转的问题的更多相关文章

  1. ios实现屏幕旋转的方法

    1.屏蔽AppDelegate下面的屏幕旋转方法 #pragma mark - 屏幕旋转的 //- (UIInterfaceOrientationMask)application:(UIApplica ...

  2. iOS屏幕旋转 浅析

    一.两种orientation 了解屏幕旋转首先需要区分两种orientation 1.device orientation 设备的物理方向,由类型UIDeviceOrientation表示,当前设备 ...

  3. UI基础:视图控制器.屏幕旋转.MVC 分类: iOS学习-UI 2015-07-02 22:21 62人阅读 评论(0) 收藏

    UIViewController 视图控制器,继承自UIResponder,作用:管理视图并且响应事件 功能: 1.分担APPdelegate的工作 2.实现模块独立,能提高复用性 创建UIViewC ...

  4. Runtime解决屏幕旋转问题

    前言 大家或许在iOS程序开发中经常遇到屏幕旋转问题,比如说希望指定的页面进行不同的屏幕旋转,但由于系统提供的方法是导航控制器的全局方法,无法随意的达到这种需求.一般的解决方案是继承UINavrgat ...

  5. 【Android】[转] Android屏幕旋转使用OrientationEventListener的监听

    说明 遇到一个奇葩的问题,我在使用onConfigChanged拦截屏幕的横竖屏旋转时,发现直接进行180度的横屏/竖屏转换居然没有反应!查找原因发现仅对landscape或者portrait状态有用 ...

  6. Android 屏幕旋转 处理 AsyncTask 和 ProgressDialog 的最佳方案

    的最佳方案 标签: Android屏幕旋转AsyncTaskProgressDialog 2014-07-19 09:25 39227人阅读 评论(46) 收藏 举报 分类: [android 进阶之 ...

  7. iOS实现屏幕旋转

    iOS实现屏幕旋转有两种方式 1. 应用本身支持 2. 手动旋转UIView (这种方式我没找到旋转 系统控件的方法 如:键盘.导航.UIAlertView) 如果你只是要把竖屏的播放器,做成支持横屏 ...

  8. Recovery和Charger模式下屏幕旋转180度

    转自:http://www.etwiki.cn/android/1267.html 如何让Recovery (系统固件升级),charger(关机充电动画)时屏幕旋转180度 解决方法: 1.在boo ...

  9. View页面内容的旋转,在某些情况下可替代屏幕旋转使用

    这个是在做小秘书的体重曲线图的时候用到的,横排的时候可以多显示些内容,可是由于很多未知的冲突导至屏幕旋转起来非常麻烦,可用用旋转页面的内容来达到旋转屏幕的效果. 代码如下: //旋转90度 CGAff ...

随机推荐

  1. [LeetCode]题解(python):067-Add Binary

    题目来源: https://leetcode.com/problems/add-binary/ 题意分析: 这题是要将二进制相加,比如“11”,“1”,那么就返回“100”. 题目思路: 模拟加法的过 ...

  2. Primavera 6.0

    Primavera 6.0(原p3e/c)荟萃了P3软件20年的项目管理精髓和经验,采用最新的IT技术,在大型关系数据库Oracle和MS SQL Server上构架起企业级的.包涵现代项目管理知识体 ...

  3. InfoQ文章

    http://www.infoq.com/cn/presentations/log-platform-construction-weipinhui https://github.com/Telesco ...

  4. Protel99se轻松入门:一些高级设置和常用技巧

    给PCB补泪滴的具体操作 这里我们可以知道给PCB做覆铜是多么的简单 在PCB中如何找到我们要找的封装 在PCB中如何打印出中空的焊盘(这个功能对于热转印制板比较有用) 如何在PCB文件中加上漂亮的汉 ...

  5. Qt多线程编程总结(一)(所有GUI对象都是线程不安全的)

    Qt对线程提供了支持,基本形式有独立于平台的线程类.线程安全方式的事件传递和一个全局Qt库互斥量允许你可以从不同的线程调用Qt方法. 这个文档是提供给那些对多线程编程有丰富的知识和经验的听众的.推荐阅 ...

  6. [置顶] MongoDB 分布式操作——分片操作

    MongoDB 分布式操作——分片操作 描述: 像其它分布式数据库一样,MongoDB同样支持分布式操作,且MongoDB将分布式已经集成到数据库中,其分布式体系如下图所示: 所谓的片,其实就是一个单 ...

  7. Convert Sorted List to Binary Search Tree ------C++ 递归创建平衡二叉查找树

    有序链表 0->1->2->3->4->5 转换为一个二叉排序树.我们在此创建一个平衡二叉排序树 1.先找链表到中间的节点 2.中间节点的val创建一个新的树节点Tree ...

  8. vmware 几种联网的方式,怎样实现虚拟机上网

    我的pc有一个IP地址是可以訪问网络的,那么如何让VM可以共享我的IP地址,也能上网呢.今天在摸索中实现了,详细的配置例如以下: 1,首先将VM的网卡net8启用: 2,然后将VM的网卡设置为VMne ...

  9. js 常用的一些函数

    //设置默认焦点    var setFocus = function SetFocus(elementId) {        document.onkeydown = function (even ...

  10. Xcode 新版本如何设置ARC

    在刚刚开始学习IOS开发时,最好不要开启ARC,这样有助于学习内存管理,但不少刚刚接触Xcode的朋友可能会发现,当你使用最新版本的Xcode时,敲入release等代码时会提示报错.这是因为系统默认 ...