UIImagePicker must be presented differently on iPhone and iPad. On the iPad, it throws an exception saying this:
* Terminating app due to uncaught exception
‘NSInvalidArgumentException’, reason:
‘On iPad, UIImagePickerController must
be presented via UIPopoverController’
So I must add code to my universal app which is iPad specific. What is a safe way to do it so that the app won’t crash on devices which lack a UIPopoverController?
Example:
popover = [[UIPopoverController alloc] initWithContentViewController:imagePicker];
[popover presentPopoverFromRect:CGRectMake(100, 100.0, 0.0, 0.0)
inView:self.view
permittedArrowDirections:UIPopoverArrowDirectionAny
animated:YES];
Also, in case I need a UIPopoverController, I need an instance variable that holds it. How would I handle this?
You can check to see if a class exists by doing this.