Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Collectively we've come to the conclusion that this is a bug in iOS 7 on iPad. It occurs when you attempt to show a UIImagePickerController in a UIPopoverControl from a UIBarButtonItem for the first time. After the user grants permission to their photo album the crash happens. It appears the solution for now is to request permission to photos before opening the UIPopoverControl. Here is how I implemented my solution:</p> <pre><code>// Photo Library if ([UIImagePickerController isSourceTypeAvailable:UIImagePickerControllerSourceTypePhotoLibrary]) { void(^blk)() = ^() { UIImagePickerController* picker = [[UIImagePickerController alloc] init]; picker.delegate = self; picker.sourceType = UIImagePickerControllerSourceTypePhotoLibrary; if (NIIsPad()) { UIPopoverController* popover = [[UIPopoverController alloc] initWithContentViewController:picker]; [popover presentPopoverFromBarButtonItem:self.popoverAnchor permittedArrowDirections:UIPopoverArrowDirectionAny animated:YES]; } else { [self.navigationController presentModalViewController:picker animated:YES]; } }; // Make sure we have permission, otherwise request it first ALAssetsLibrary* assetsLibrary = [[ALAssetsLibrary alloc] init]; ALAuthorizationStatus authStatus; if (IOS_VERSION_GREATER_THAN_OR_EQUAL_TO(@"6.0")) authStatus = [ALAssetsLibrary authorizationStatus]; else authStatus = ALAuthorizationStatusAuthorized; if (authStatus == ALAuthorizationStatusAuthorized) { blk(); } else if (authStatus == ALAuthorizationStatusDenied || authStatus == ALAuthorizationStatusRestricted) { [[UIAlertView alertViewWithTitle:@"Grant photos permission" message:@"Grant permission to your photos. Go to Settings App &gt; Privacy &gt; Photos."] show]; } else if (authStatus == ALAuthorizationStatusNotDetermined) { [assetsLibrary enumerateGroupsWithTypes:ALAssetsGroupAll usingBlock:^(ALAssetsGroup *group, BOOL *stop) { // Catch the final iteration, ignore the rest if (group == nil) dispatch_async(dispatch_get_main_queue(), ^{ blk(); }); *stop = YES; } failureBlock:^(NSError *error) { // failure :( dispatch_async(dispatch_get_main_queue(), ^{ [[UIAlertView alertViewWithTitle:@"Grant photos permission" message:@"Grant permission to your photos. Go to Settings App &gt; Privacy &gt; Photos."] show]; }); }]; } } </code></pre> <p>Don't forget to add AssetsLibrary.framework to your project.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload