【发布时间】:2014-05-21 04:40:11
【问题描述】:
我有一个仅处于横向模式的应用程序。在我的应用程序中,我从我的一个视图中打开相机。它在我的 iPad 上运行良好,但在 iPhone 上它崩溃了。它在 iOS 6 中运行良好,但应用在 iOS 7 和 iPhone 上崩溃。
下面是我的代码。
if([UIImagePickerController isSourceTypeAvailable:UIImagePickerControllerSourceTypeCamera])
{
ipc=[[UIImagePickerController alloc] init ];
ipc.delegate=self;
ipc.sourceType=UIImagePickerControllerSourceTypeCamera;
[self presentViewController:ipc animated:YES completion:nil];
}
else {
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Desc" message:@"Camera capture is not supported in this device" delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil, nil];
[alert show];
[alert release];
}
如何解决这个问题?
当我选择从相机捕捉时它崩溃了。它不会从上面的代码中崩溃,但之后它会崩溃并出现以下错误。
我收到此错误:
由于未捕获的异常'UIApplicationInvalidInterfaceOrientation'而终止应用程序,原因:'支持的方向与应用程序没有共同的方向,并且 shouldAutorotate 正在返回 YES
我的应用程序崩溃了。
我在这个视图上的定位代码。
-(BOOL)shouldAutorotate
{
return YES;
}
-(NSUInteger)supportedInterfaceOrientations
{
return UIInterfaceOrientationMaskLandscapeLeft | UIInterfaceOrientationMaskLandscapeRight ;
}
【问题讨论】:
标签: ios iphone objective-c ios7 uiimagepickercontroller