zoukankan      html  css  js  c++  java
  • ios6:UIImagePickerController & Rotation

    项目是在ipad上的横屏的项目,运行在ios6上时,在用到选择本地相册的时候崩溃:

    “Terminating app due to uncaught exception 'UIApplicationInvalidInterfaceOrientation', reason: 'Supported orientations has no common orientation with the application, and shouldAutorotate is returning YES”

    一查原来是ios6的rotation较之前有了改动。ios6丢弃了shouldAutorotateToInterfaceOrientation的方法,代替的是supportedInterfaceOrientations 、shouldAutorotate 、preferredInterfaceOrientationForPresentation等方法,具体变化见:iOS 6的Rotation

    因为项目要求是全部横屏,但是UIImagePickerController又是竖屏显示的。违反了ios6对Rotation的新规定。最终在http://code4app.com/requirement/5074e36b6803fa8445000000

    找到答案。

    在appdelegate添加

    #if __IPAD_OS_VERSION_MAX_ALLOWED >= __IPAD_6_0
    
    - (NSUInteger)application:(UIApplication *)application supportedInterfaceOrientationsForWindow:(UIWindow *)window
    {
        return UIInterfaceOrientationAllMask;
    }
    #endif

    然后在你UIImagePickerController的top-most VC中添加:

    - (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
    {
        return (interfaceOrientation == UIInterfaceOrientationLandscapeLeft||interfaceOrientation==UIInterfaceOrientationLandscapeRight);
    }
    
    //ios 6 rotation 
    -(NSUInteger)supportedInterfaceOrientations{
        return UIInterfaceOrientationLandscapeMask;
    }  
      
    - (BOOL)shouldAutorotate  
    {  
        return YES;  
    }

    问题解决!

     

  • 相关阅读:
    快速获取一个正数的掩码
    使用pdfbox删除pdf指定文字内容
    判断奇偶性
    RabbitMQ高级特性
    常见排序算法
    postman和postman interceptor的安装
    Linux命令
    Chrome 错误代码:ERR_UNSAFE_PORT
    IDEA运行tomcat控制台乱码
    Spring Boot 项目架构
  • 原文地址:https://www.cnblogs.com/mybkn/p/2755716.html
Copyright © 2011-2022 走看看