Io lavoro su iPad 4 con iOS 6.0.UIIMagePickerController si arresta in modo anomalo quando si chiude su iPad ios 6.0
Ho una ViewController (MyPickerController) con il seguente init:
- (id)init
{
self = [super init];
if (self) {
_picker = [[UIImagePickerController alloc] init];
_picker.delegate = self;
_picker.sourceType = UIImagePickerControllerSourceTypeCamera;
[self.view addSubview:_picker.view];
}
return self;
}
I attuare il seguente metodo UIPickerControllerDelegate a dimiss MyPickerController:
- (void)imagePickerControllerDidCancel:(UIImagePickerController *)picker
{
[self dismissViewControllerAnimated:YES completion:nil];
}
Ebbene, ho un altro controllore vista mostrato modale in FormSheetStyle
e quando tocco un pulsante voglio mostrare MyPickerController
con il seguente codice:
MyPickerController * pickerVC = [[MyPickerController alloc] init];
[self presentViewController:pickerVC animated:YES completion:nil];
Nel mio AppDelegate ho il seguente metodo totation:
- (NSUInteger)application:(UIApplication *)application supportedInterfaceOrientationsForWindow:(UIWindow *)window {
return (NSUInteger)[application supportedInterfaceOrientationsForWindow:window] | (1<<UIInterfaceOrientationPortrait);
}
Quando si tocca il tasto di UIIMagePicker
annullo in MyPickerController
, l'applicazione si blocca con il seguente errore:
Terminating app due to uncaught exception 'UIApplicationInvalidInterfaceOrientation', reason: 'preferredInterfaceOrientationForPresentation must return a supported interface orientation!
lettura questioni connesse su stackoverflow, creo anche la seguente categoria UIImagePickerController follower:
@implementation UIImagePickerController (NonRotating)
- (BOOL)shouldAutorotate
{
return NO;
}
- (UIInterfaceOrientation)preferredInterfaceOrientationForPresentation
{
return UIInterfaceOrientationMaskPortrait;
}
- (NSUInteger)supportedInterfaceOrientations
{
return UIInterfaceOrientationMaskPortrait;
}
@end
Grazie!
perché si aggiunge la vista della raccoglitrice come una visualizzazione secondaria del vostro vista? –