我的应用程序仅在横向模式下在iPad上运行,但图像选择器会抛出以下错误

时间:2014-07-10 07:32:03

标签: ios ipad

DriverWorkDiary [2564:60b] *由于未捕获的异常终止应用程序' UIApplicationInvalidInterfaceOrientation',原因:'支持的方向与应用程序没有共同的方向,并且shouldAutorotate返回YES&# 39; * 第一次抛出调用堆栈: (0x2ff30fd3 0x3aaf8ccf 0x2ff30f15 0x327be4fb 0x327c5b05 0x327c5ab9 0x327c4bf9 0x3274c729 0x3274c507 0x3274be71 0x3274bcc5 0x32758a6f 0x327584df 0x32803ccf 0x32803aeb 0x327fb995 0x327fae1d 0x327fab8d 0x327fab25 0x3274cd79 0x323ca62b 0x323c5e3b 0x323c5ccd 0x323c56df 0x323c54ef 0x323bf21d 0x2fefc2a5 0x2fef9c49 0x2fef9f8b 0x2fe64f4f 0x2fe64d33 0x34d8a663 0x327b016d 0xf7ca5 0x3b005ab7) libc ++ abi.dylib:以NSException类型的未捕获异常终止

这是我的代码:

if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad) {
    UIImagePickerController *picker;
    if ([UIImagePickerController isSourceTypeAvailable:UIImagePickerControllerSourceTypePhotoLibrary]) {
        picker = [[UIImagePickerController alloc] init];
        picker.delegate = self;
        picker.sourceType = UIImagePickerControllerSourceTypePhotoLibrary;
        [self presentViewController:picker animated:YES completion:NULL];
    }    
} else {
    UIImagePickerController *picker;
    if ([UIImagePickerController isSourceTypeAvailable:UIImagePickerControllerSourceTypePhotoLibrary]) {
        picker = [[UIImagePickerController alloc] init];
        picker.delegate = self;
        picker.sourceType = UIImagePickerControllerSourceTypePhotoLibrary;

        [self presentViewController:picker animated:YES completion:NULL];
    }
}

0 个答案:

没有答案