*** Terminating app due to uncaught exception 'UIApplicationInvalidInterfaceOrientation', reason: 'S

       在调用  UIImagePickerController  显示图片库的时候,显示如题的错误。


         后面发现论坛上有这个问题的解决方法,记录如下:


      1.  在AppDelegate里面添加这个方法就OK了


#if __IPHONE_OS_VERSION_MAX_ALLOWED >= __IPHONE_6_0 

- (NSUInteger)application:(UIApplication *)application supportedInterfaceOrientationsForWindow:(UIWindow *)window
{
    return UIInterfaceOrientationMaskAll;
}

#endif


  如果程序不是只支持横屏,而是横屏竖屏都支持的,那么就 到1 就可以解决了。但是,如果程序只支持横屏,这个解决方法就会导致一个问题:

  所有的界面都可以支持竖屏了,这个不是我们想要的,那么就需要添加下面的步骤。


2 .   从 

UINavigationController

  派生出一个 自己的类 MyRootViewController

  类里面加上这么几个方法:

-(NSUInteger)supportedInterfaceOrientations

{

    returnUIInterfaceOrientationMaskLandscape;

}


- (BOOL)shouldAutorotate {

    return YES;

}



// Override to allow orientations other than the default portrait orientation.

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation

{

    // Return YES for supported orientations

    return (interfaceOrientation == UIDeviceOrientationLandscapeLeft  ||

            interfaceOrientation == UIDeviceOrientationLandscapeRight);

    

}



3.  找到appDelegate的 laugth方法中,替换为:

    

    

// Create a Navigation Controller with the Director

navController_ = [[MyRootViewControlleralloc] initWithRootViewController:director_];

navController_.navigationBarHidden =YES;


     在.h文件中,将 navController_ 的定义 改为 MyRootViewController


4.到此,就完美解决了。感谢网络,感谢google .


  • 0
    点赞
  • 5
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值