2013-01-18 15 views
6

私は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と表示されます。

私AppDelegateで

私持って、次の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のキャンセルボタン

stackoverflowで、私はまた、次のUIImagePickerControllerカテゴリを作成します:

@implementation UIImagePickerController (NonRotating) 

- (BOOL)shouldAutorotate 
{ 
   return NO; 
} 

- (UIInterfaceOrientation)preferredInterfaceOrientationForPresentation 
{ 
   return UIInterfaceOrientationMaskPortrait; 
} 

- (NSUInteger)supportedInterfaceOrientations 
{ 
   return UIInterfaceOrientationMaskPortrait; 
} 

@end 

ありがとうございました!

+0

あなたのサブビューとしてピッカーのビューを追加する理由見る? –

答えて

2

これをやって試してみてください。..

をあなたのビューコントローラがUINavigationControllerの内部にある場合、あなたはnavigationcontrollerのために、このカテゴリを使用する必要があります。

@implementation UINavigationController (autorotate) 

- (NSUInteger)supportedInterfaceOrientations{ 
     return UIInterfaceOrientationMaskAll; 
} 

- (UIInterfaceOrientation)preferredInterfaceOrientationForPresentation{ 
     return UIInterfaceOrientationMaskPortrait; 
} 


@end 
関連する問題