最近在公司移植一款PAD应用,在使用相册和拍照功能时直接crash掉了,控制台没有任何输出,这个问题纠结了半天。
使用EXCEPTION BREAKPOINT 捕获所有异常,显示 下面这条代码出问题
[self.navigationController presentViewController:imagePickerView animated:YES completion:nil];
看代码也没问题,就是在这个位置crash 掉,控制 台没有任何信息,很郁闷。
总结如下:
没有任何错误输出的情况下,使用try cash 代码块捕获异常,再把异常信息打印出来
preferredInterfaceOrientationForPresentation must return a supported interface orientation//这是我打印的错误 信息,说是要返回一个支持的方向。
因为我的应用支持屏幕旋转,但相册库只支持竖屏方向,拍照功能可以横屏竖屏,现在需要在视图控制器的根视图控制器填加如下几个方法
-(BOOL)shouldAutorotate{
return YES;
}
-(NSUInteger)supportedInterfaceOrientations{
return UIInterfaceOrientationMaskAll;
}
-(UIInterfaceOrientation)preferredInterfaceOrientationForPresentation{
// return UIInterfaceOrientationMaskPortrait;
if ([self isKindOfClass:[UIImagePickerController class]]) {
return UIInterfaceOrientationPortrait;
}
return UIInterfaceOrientationPortrait | UIInterfaceOrientationLandscapeLeft|UIInterfaceOrientationLandscapeRight;
}
我的项目需要在UISplitViewController 和 UINavigationController 中设置。
这个问题挺吭了,耗费不少时间来解决这个问题,