Camera->openLibrary(); on iPad (ofxiPhoneImagePicker)

Has anyone worked out a method to get images from library on the iPad?

On the iPhone we used camera->openLibrary(); using the “ofxiPhoneImagePicker” which works great but on the iPad the console reports:

2010-09-05 09:27:48.808 SKTCH[14792:207] *** Terminating app due to uncaught exception ‘NSInvalidArgumentException’, reason: ‘On iPad, UIImagePickerController must be presented via UIPopoverController’


1 Like

On the iPhone, the UIImagePicker is displayed fullscreen. On the iPad, it should be displayed in a popover view. I’m working on a fix for the iPad as I also need it for an app I’m working on. I’ll post it here when I have something that works.

Thanks janvantomme

Got the image picker working on the iPad. Only tested it in the simulator right now but I think it should be fine on the device. Loading files of 2048 x 2048 pixels works fine, files of 12 megapixels fail to display.

I’ve used standard UIKit interface elements in an extra Objective-C class. Note that you have to change the extension of this class to .mm. If you don’t do this, the app will not compile.

Hi @janvantomme and @filip, any chance to get that .zip again?
The link is broken unfortunately…
Thanks a lot!

You don’t need this zip. The code is from 4 years ago when support for the image picker wasn’t implemented that well in OF. Probably wouldn’t work anymore since that project was made with OF 0.6.1.

You can use the ofxiOSImagePicker class now to do this. There’s a openLibrary() and an openSavedPhotos() method. Documentation over here:

Hey, thanks for the reply!

The current picker has issues, for me it crashes on my iPad3 with iOS 6 on openLibrary() with this error message:

*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: 'On iPad, UIImagePickerController must be presented via UIPopoverController'

In the simulator with iOS 7.1 it works though.

There’s a lengthy discussion on github as well, people mention several issues, and it’s obviously not ideal how you have to use it, polling imageUpdated.
Apparently there’s plans for an update, but I wouldn’t hold my breath, cause the discussion is rather old.

Did you code everything from scratch, or just modified the ObjC part, and did you use a UIPopoverController?
Was hoping I could peek into the code for some cues, my ObjC knowledge is rather limited but I’m occasionally successful at muddling through… :wink:

I coded most of it from scratch. The image picker I used is called from a toolbar. All UI in the app is Objective-C and some XIB files. When the image is loaded it is converted with iPhoneUIImageToOFImage() to something OF can use.

Starting point for me was the iPhoneGUIExample and a bit of searching on Stack Overflow for the Objective-C code.

This is the app: The code for this app doesn’t compile anymore on my machine with the last version of Xcode.

Ok, thanks anyway!
Had a look at the GUI example initially, but it’s broken too… :wink:

Nice app btw!