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];
}
逻辑上的一个错误是,如果isSourceTypeAvailable
在iPhone上返回NO,则您将尝试提供一个nil
的控制器。
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.