UIImagePickerController没打开

在应用中打开一个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;
}

谢谢

shouldAutorotate return NO,改成return YES试试

- (BOOL) shouldAutorotate
{
    return YES;
}