2013-01-18 21 views
6

पर खारिज करने पर क्रैश पर मैं आईओएस 6.0 के साथ आईपैड 4 पर काम करता हूं।आईआईएमआईएमपीकर नियंत्रक क्रैश आईपैड आईओएस 6.0

मैं एक ViewController (MyPickerController) निम्नलिखित init साथ:

- (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 निम्नलिखित UIPickerControllerDelegate तरीका लागू FormSheetStyle और जब मैं एक बटन पर टैप करता हूं तो मैं निम्नलिखित कोड के साथ MyPickerController दिखाना चाहता हूं:

MyPickerController * pickerVC = [[MyPickerController alloc] init]; 
[self presentViewController:pickerVC animated:YES completion:nil]; 

मेरे AppDelegate में मैं निम्नलिखित totation विधि:

- (NSUInteger)application:(UIApplication *)application supportedInterfaceOrientationsForWindow:(UIWindow *)window { 
    
   return (NSUInteger)[application supportedInterfaceOrientationsForWindow:window] | (1<<UIInterfaceOrientationPortrait); 
    
} 

जब मैं पर टैप निम्न त्रुटि के साथ MyPickerController में UIIMagePicker के बटन को रद्द, अनुप्रयोग क्रैश:

Terminating app due to uncaught exception 'UIApplicationInvalidInterfaceOrientation', reason: 'preferredInterfaceOrientationForPresentation must return a supported interface orientation! 

संबंधित प्रश्नों पढ़ना स्टैक ओवरफ्लो पर, मैं फॉलोइंग यूआईमेमेज पिकर कंट्रोलर श्रेणी भी बनाता हूं:

@implementation UIImagePickerController (NonRotating) 

- (BOOL)shouldAutorotate 
{ 
   return NO; 
} 

- (UIInterfaceOrientation)preferredInterfaceOrientationForPresentation 
{ 
   return UIInterfaceOrientationMaskPortrait; 
} 

- (NSUInteger)supportedInterfaceOrientations 
{ 
   return UIInterfaceOrientationMaskPortrait; 
} 

@end 

धन्यवाद! आपके विचार नियंत्रक एक UINavigationController के अंदर है, तो

+0

कारण है कि आप का एक subview के रूप पिकर का दृश्य जोड़ने अपने राय? –

उत्तर

2

यह करके देखें ..

, आप navigationController के लिए इस श्रेणी का उपयोग करना चाहिए:

@implementation UINavigationController (autorotate) 

- (NSUInteger)supportedInterfaceOrientations{ 
     return UIInterfaceOrientationMaskAll; 
} 

- (UIInterfaceOrientation)preferredInterfaceOrientationForPresentation{ 
     return UIInterfaceOrientationMaskPortrait; 
} 


@end