Looks like no one’s replied in a while. To start the conversation again, simply ask a new question.

Subclassing UIImagePickerController?

I'm trying to modify the UI that the user is presented with when they're taking a picture. Specifically, I want to remove the "Take Picture" title bar and replace it with a custom graphic.

I'm a little lost on how to start. If anyone could share some thoughts (or even a tiny bit of code) I'd greatly appreciate it.

Thanks


-hack

Mac OS X (10.5.4)

Posted on Sep 14, 2008 3:50 PM

Reply
Question marked as Top-ranking reply

Posted on Sep 14, 2008 6:01 PM

A picker controller is just a UIViewController. A view controller has a UIView (view). A view has subviews. I'd start by using the debugger and NSLog statements and dig into the view structure trying to find out what's in there. Once you know the components you might be able to replace or change them.

Keep in mind that whatever you do in this regard could break anytime Apple puts out an update.
12 replies
Sort By: 
Question marked as Top-ranking reply

Sep 14, 2008 6:01 PM in response to hack4

A picker controller is just a UIViewController. A view controller has a UIView (view). A view has subviews. I'd start by using the debugger and NSLog statements and dig into the view structure trying to find out what's in there. Once you know the components you might be able to replace or change them.

Keep in mind that whatever you do in this regard could break anytime Apple puts out an update.
Reply

Sep 14, 2008 6:42 PM in response to RickMaddy

Thanks, that helps quite a bit. We've been trying to see how the view is composed, but that's proven difficult. We can obviously get into the UIImageController.h which is quite modest. Could I trouble you to explain a little further how we'd find out where the title text "Take picture", for example, is happening?
Reply

Sep 14, 2008 7:01 PM in response to hack4

Iterate over all the subviews in the controller's view. Print the class name for each. The text could be a title for a nav bar or tool bar. Or it could just be rendered text which will make it more difficult to replace because then you will need to draw over it.

The header file may not help because most (if not all) of the subviews are not referenced in an instance variable.

Something like this in your controller:


for (UIView *view in self.view.subviews) {
 NSLog(@"view is a %@", [view description]);
}


Run this in 'viewDidAppear:' or something similar.
Reply

Sep 14, 2008 8:07 PM in response to Scott Squires1

Right, I've thought about that.

I know that Phanfare directly bypassed the Image Picker and wrote their own, and their app was pulled for that reason. They then reverted to Apple's interface (though they've subclassed it much in the way I'd like to) and Apple reinstated their app in the store.
Reply

Sep 15, 2008 8:17 AM in response to RickMaddy

Fantastic. I'm currently iterating through all (two) of the picker's subviews when I create it, and I've been able to arbitrarily add my own. Removing the UINavigationBar subview doesn't seem to be reflected in my app, though. I can remove it before I check the subviews, and it's no longer listed, but I'm still seeing it within the application, which is puzzling. (The same goes for setting hidden=YES.)
Reply

Sep 16, 2008 1:26 PM in response to hack4

I'm having a very similar problem. I'd like to get rid of the standard "Take Picture" navigation bar. What's here so far has been helpful, but I still haven't had any luck getting rid of it. Any help would be very much appreciated.

(As an example, Phanfare has a custom bar at the top showing upload progress).
Reply

Sep 16, 2008 1:40 PM in response to drummerd_ca

I just found an easy way to do this. UIImagePickerController takes a delegate. This delegate has two protocols - UIImagePickerControllerDelegate and UINavigationControllerDelegate. I added the 'willShowViewController' delegate method to my class. This will get called just before the image picker displays.

This method gets passed a navigation controller and a view controller. You can do something like this:


- (void)navigationController:(UINavigationController *)navigationController willShowViewController:(UIViewController *)viewController animated:(BOOL)animated {
 UINavigationBar *bar = navigationController.navigationBar;
 UINavigationItem *top = bar.topItem;
 top.prompt = @"Custom prompt on my picker";
 top.title = @"Custom Picker Title";
}



Now that you have access to the navigation item you can customize all you want including setting a custom title view. This may be what Phanfare is doing.

I know this works with an image picker of type 'Saved Photos Album' because I'm doing it as of 30 minutes ago. I'm assuming it will work with the 'Camera' picker too.
Reply

Oct 1, 2008 3:39 PM in response to drummerd_ca

Hello,

After much trial and error, I finally figured out how to add my own views to the tab bar for the camera control (similar to Phanfare - see http://help.phanfare.com/index.php/PhanfareiPhoneApplication). However, I would like to remove the translucent "Take Picture" text label (which I assume is a subview of the main view). Anybody have any ideas how to hide/remove it?

Thanks.
Reply

Oct 1, 2008 7:18 PM in response to hack4

This is a nice technique. I am experiencing one quirk.

I had added a UIBarButtonItem as the leftBarButtonItem of the UINavigationItem in the album photo picker and it looks and works fine.

However, if the user clicks on an album in the picker to drill into the contents of that album, my custom left button quickly jumps up several pixels as the navigation animation wipes to the left to display the next view. It looks really bad, and I am just wondering if anyone has ideas as to why this happens, or if there might be a workaround.
Reply

Nov 12, 2008 6:03 AM in response to RickMaddy

It works for the camera capture too - just wrote a short article on my blog discussing the view hierarchy that you can manipulate:

See: http://blog.airsource.co.uk/index.php/2008/11/11/views-of-uiimagepickercontrolle r/

www.airsource.co.uk - Airsource Ltd. - Mobile Software Experts
blog.airsource.co.uk - The Airsource - A blog on mobile software
Reply

Subclassing UIImagePickerController?

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple Account.