我想使用此代碼在我的應用程序中打開UIImagePickerController
對象:的UIImagePickerController iOS中不開放6.0
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
?
檢查這個http://stackoverflow.com/questions/12690963/preferredinterfaceorientationforpresentation-must-return-a-supported-interface-o – Manthan
iPhone或iPad? –