Andy Reitz (blog)

 

 

My iPhone app can now choose photos

| 2 Comments

Well, it took several days of hacking, but I finally figured out what was wrong with the iPhone app that I tried to code over the weekend, and it can display the photo picker now. The problem that I was having is that I was sending presentModalViewController: message to my UIViewController instance, as opposed to my UINavigationController instance. I mean, duh!

The actual, real, problem is that I'm still mighty confused by Cocoa, and only slightly confused by Objective-C. Now that I'm past this major hurdle, I hope to find myself in a state of less confusion soon. Of course, I still don't know how to handle the image, once the user has chosen it in the image picker...

Anyway, I have posted my sample code - if you download this code and build the project in Xcode 3.1, the resulting application should throw up the Photo Picker control, and then do nothing once you choose an image. Note that I am not the best Objective-C programmer (see above), so there are probably tons of mistakes and memory leaks in this sample code. But it does provide a complete reference of how to use the UIImagePickerController class, which Apple's documentation only gives hints about.

-Andy.

 

 

2 Comments

Have you tested this on an actual device? It doesn't work on an iPod Touch. I have a similar application that doesn't work either. They both throw an exception on the call that would display the picker.

Hi Pete,

I haven't tested my code on my iPhone yet - I haven't applied for the $99 certificate that is required to load custom applications onto the iPhone for development purposes. Even if I had applied, it looks like I wouldn't have been accepted into the beta program (yet) anyway...

-Andy.

Leave a comment