Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

iOS

Embedding a UIImagePickerController inside of a UINavigationController

I am starting to work on my own app now and am using some picture functionality inside of it. My problem can be seen also inside of the Ribbit app if you don't totally understand what I am saying.

Basically, when I programmatically create a UIImagePickerController it appears that it is not embedded in a UINavigationController, or at least it doesn't appear to be because the status bar overlaps with the UIImagePickerController. Is there a way to create this so that the status bar is still clearly visible from the ImagePicker?

If there is a way to disable the status bar, that would work just a well. That is how Apple does it inside their camera app

3 Answers

I actually found a really good answer in Stack Overflow. This is actually a really complicated problem in iOS 7 and it appears to be some sort of a bug. To hide the status bar in a UIImagePickerController you have to:

  1. Add a property called "View controller - based status bar" as a BOOLEAN in the info.plist and set it to NO.
  2. Add the line [appearance setStatusBarHidden:NO]; to the appDelegate.m
  3. Add the line [appearance setStatusBarStyle:UIStatusBarStyleDefault]; to the the appDelegate.m file

Not really sure why that fixes it...but...it does...so. Yup!

if you want to hide it you can implement

-(BOOL)prefersStatusBarHidden
{
    return YES;
}

then call it when you present image picker

you might also try embedding the image picker programatically in a navigation controller, though im not sure how you would do that