私はiPad 4とiOS 6.0で動作します。UIIMagePickerControllerは、iPad iOS 6.0での解雇時にクラッシュする
私は次のinitとのViewController(MyPickerController):
- (void)imagePickerControllerDidCancel:(UIImagePickerController *)picker
{
[self dismissViewControllerAnimated:YES completion:nil];
}
さて、私は別のビューコントローラがでモーダル示した:
- (id)init
{
self = [super init];
if (self) {
_picker = [[UIImagePickerController alloc] init];
_picker.delegate = self;
_picker.sourceType = UIImagePickerControllerSourceTypeCamera;
[self.view addSubview:_picker.view];
}
return self;
}
私はMyPickerController dimissには、次のUIPickerControllerDelegateメソッドを実装FormSheetStyle
ボタンをタップすると、次のコードでMyPickerController
と表示されます。
私持って、次のtotation方法:
Terminating app due to uncaught exception 'UIApplicationInvalidInterfaceOrientation', reason: 'preferredInterfaceOrientationForPresentation must return a supported interface orientation!
関連の質問を読む:
- (NSUInteger)application:(UIApplication *)application supportedInterfaceOrientationsForWindow:(UIWindow *)window {
return (NSUInteger)[application supportedInterfaceOrientationsForWindow:window] | (1<<UIInterfaceOrientationPortrait);
}
私は上をタップし、次のエラーで、MyPickerController
にアプリケーションのクラッシュをUIIMagePicker
のキャンセルボタン
@implementation UIImagePickerController (NonRotating)
- (BOOL)shouldAutorotate
{
return NO;
}
- (UIInterfaceOrientation)preferredInterfaceOrientationForPresentation
{
return UIInterfaceOrientationMaskPortrait;
}
- (NSUInteger)supportedInterfaceOrientations
{
return UIInterfaceOrientationMaskPortrait;
}
@end
ありがとうございました!
あなたのサブビューとしてピッカーのビューを追加する理由見る? –