When i try to call the photo Album from xcode 4.5 ,app crashes .
Note : I set the app orientation to landscape mode.
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];
}
One error in your logic is that if
isSourceTypeAvailablereturns NO on an iPhone you will attempt to present a controller that’snil.