我正在尝试UIImagePickerController
使用以下代码在我的应用程序中打开一个对象:
self.imgPicker = [[UIImagePickerController alloc] init];
self.imgPicker.delegate = self;
self.imgPicker.sourceType = UIImagePickerControllerSourceTypePhotoLibrary;
self.imgPicker.modalPresentationStyle = UIModalPresentationFullScreen;
[self presentViewController:self.imgPicker animated:YES completion:nil];
但随后应用程序崩溃并显示以下错误:
Terminating app due to uncaught exception 'UIApplicationInvalidInterfaceOrientation', reason:
'preferredInterfaceOrientationForPresentation must return a supported interface orientation!'
我还在ViewController
课堂上添加了以下方法
- (BOOL) shouldAutorotate
{
return NO;
}
-(NSUInteger)supportedInterfaceOrientations
{
return UIInterfaceOrientationMaskPortrait;
}
- (UIInterfaceOrientation)preferredInterfaceOrientationForPresentation
{
return UIInterfaceOrientationPortrait;
}
- (BOOL)shouldAutorotateToInterfaceOrientation: (UIInterfaceOrientation)toInterfaceOrientation {
return UIInterfaceOrientationMaskPortrait;
}
那么,我还应该做些什么来呈现这个UIImagePickerController
呢?