Quando provo a chiamare l'album fotografico da xcode 4.5, l'app si arresta in modo anomalo. Nota: ho impostato l'orientamento dell'app in modalità orizzontale.
UIImagePickerController *picker=nil;
if ([UIImagePickerController isSourceTypeAvailable:UIImagePickerControllerSourceTypeSavedPhotosAlbum])
{
picker = [[UIImagePickerController alloc] init];
picker.delegate = self;
picker.sourceType = UIImagePickerControllerSourceTypePhotoLibrary;
picker.allowsEditing = NO;
picker.mediaTypes = [UIImagePickerController availableMediaTypesForSourceType:
UIImagePickerControllerSourceTypeSavedPhotosAlbum];
}
if ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPhone ) {
[self presentViewController:picker animated:YES completion:nil];
}
risposte:
1 per risposta № 1Un errore nella tua logica è che se isSourceTypeAvailable
restituisce NO su un iPhone che tenterai di presentare un controller che "s nil
.