Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>I tried your code and can reproduce the crash in the simulator. But it is working fine on my iPhone 4 with iOS 4.2.</p> <p>That said, I made my gallery in the simulator contain some photos. (Start in-simulator Safari, open some page, save some pictures by long pressing on them and choosing save from the menu.)</p> <p>Now, the simulator writes </p> <pre><code>2012-05-08 15:53:55.605 test[5870:f803] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: 'On iPad, UIImagePickerController must be presented via UIPopoverController' </code></pre> <p>to the console.</p> <p>Okay, read, done:</p> <pre><code>-(IBAction)getPhoto:(UIButton *)sender { if ([UIImagePickerController isSourceTypeAvailable:UIImagePickerControllerSourceTypePhotoLibrary]) { if (myPhotopicker==nil) { myPhotopicker = [[UIImagePickerController alloc] init]; myPhotopicker.delegate = self; }// create once! myPhotopicker.sourceType = UIImagePickerControllerSourceTypePhotoLibrary; if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad) { // iPad Code: UIPopoverController *popover = [[UIPopoverController alloc] initWithContentViewController:myPhotopicker]; [popover presentPopoverFromRect:sender.bounds inView:self.view permittedArrowDirections:UIPopoverArrowDirectionAny animated:YES]; } else { // iPhone Code: [self presentModalViewController:myPhotopicker animated:YES]; } } else { NSLog(@"Photo Album is not available!"); } } </code></pre> <p>And now it looks like that:<br> <img src="https://i.stack.imgur.com/EDpOg.png" alt="enter image description here"></p>
 

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