简体   繁体   中英

Crash at self.view presentviewcontroller:UIImagePickerController in iOS 6

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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM