Missing: iPad buttons
August 10, 2011 9:46 AM   Subscribe

I'm writing my first iPad 2 app. How can I include the standard iOS buttons for taking a photo and for switching/flipping between front and back cameras? I'm talking strictly about the appearance of the buttons, not about the SDK and the frameworks.

I'm using openFrameworks (http://www.openframeworks.cc) for most of the coding. I do have a standard iOS toolbar at the bottom of my app, and right now I have 2 Bar Button Items that say "Take Photo" and "Switch Camera" that call into my code and I handle the functionality manually. So they both do what they say, and I could leave them this way, but it would be nicer to make use of the standard iOS buttons. But I don't see a way of doing this in Interface Builder. I can't change the buttons to show the appropriate button images.

I did see a way of changing the Bar Button Item to a "Camera" setting, but this is not the right icon/button - it's for the lock screen's camera button.

One way of achieving this would be to use images for the Bar Button Items. But I'm not seeing any such images inside Apple's sample projects that use the camera.

I've posted on Apple's dev forum, but thought I'd try here too. Thanks for any help.
posted by shortfuse to Computers & Internet (4 answers total) 1 user marked this as a favorite
 
Is UIBarButtonSystemItemCamera the icon you want? If so, you want to create a toolbar button withinitWithBarButtonSystemItem:target:action:.

If not, and you're looking for the icons that appear in the native Camera app, I don't think those are available. You'll have to use images. Most of Apple's sample projects will probably use UIImagePickerController to present the camera, which will use those Camera app icons, but it sounds like you're doing camera control directly.
posted by ignignokt at 10:09 AM on August 10, 2011


Response by poster: Yes that icon from the first part of your answer would work, and I can set it using Interface Builder. The problem for me is that it locks the button's size to fit the icon, and I can't change the size. This means 2 problems: (1) A camera button with that tight-fit size is usually seen on the lock screen, which means pressing it should bring up a full camera mode screen, which isn't what I'm doing at all; (2) A small camera button looks odd on the iPad - I need a wider button like in Photo Booth or Camera.

I think I'm gonna have to go with images. I've been trying this in the meantime, but I can't seem to put PNG images into Bar Button Items? They come up white squares. Arg.

Thanks for your reply.
posted by shortfuse at 10:23 AM on August 10, 2011


Oh, yeah, the wacky thing about bar button images is that only the alpha values in the image are considered. This is so iOS can make the button image just a white shape that doesn't clash - color-wise - with the rest of the toolbar.

However, you can get around that by using initWithCustomView: and using a UIButton or UIImage with the image loaded as your custom view.
posted by ignignokt at 10:36 AM on August 10, 2011


You could scale up the default system image to keep the UI consistent.
posted by adventureloop at 11:17 AM on August 10, 2011


« Older I fail as an engineer..   |   Tell me what it was like when you first met your... Newer »
This thread is closed to new comments.