PDA

View Full Version : UIImagePickerController overlapped by status bar screen area




amagic84
Apr 30, 2011, 12:34 AM
Hi,

I'm calling presentModalViewController:animated: to show UIImagePickerController from my UITabBarController and I'm seeing a weird problem. UIImagePickerController takes the whole screen but then around top 20 px (looks about the same area where the status bar resides) is overlapped with the bottom portion of what appears to be the bottom of a blue navigation bar. I can only see the bottom of the bar text but I think it says "Root View Controller". Now I have UINavigationControllers in my project but none of them are named that.

Any thoughts or ideas on how to fix this? Any help is much appreciated.
Thanks!

amagic



balamw
Apr 30, 2011, 06:18 AM
Can you post a screenshot?

B

amagic84
Apr 30, 2011, 10:52 AM
Sure, here's a screenshot: http://img543.imageshack.us/img543/2256/photohc.png

Here's how I invoke presentation image picker:

imagePickerController = [[UIImagePickerController alloc] init];

imagePickerController.delegate = self;
imagePickerController.sourceType = UIImagePickerControllerSourceTypeCamera;

NSLog(@"View: %@", imagePickerController.view);

[appDelegate.navController.topViewController.tabBarController presentModalViewController:imagePickerController animated:YES];

NSLog(@"View: %@", imagePickerController.view);


I should also explain that that I have several layers of controllers in my app. The ui navigation controller is used to push around the main views (login, tutorial, and main view). The main view is controlled by a ui tab bar controller.

Now I realized last night after further testing that the view frame of ImagePicker is being changed after i call presentModalViewController. Before presentModalViewController the frame is (0, 0, 320, 480) then right after its set to (0, -20, 320, 480) which is probably the cause of this whole issue. Now, I've tried hiding and showing the status bar both before and after presenting imagePicker but to no avail.

I know its probably some simple issue but its been bugging me...

amagic84
Apr 30, 2011, 12:03 PM
One more thing, when I use one of my own view controllers in place of the image picker everything works correctly. Instead of the blue bar I see a status bar, as it should be.

PhoneyDeveloper
Apr 30, 2011, 01:52 PM
I think you're also setting an overlayview. Is it possible that the navbar is on that overlay view?

amagic84
Apr 30, 2011, 03:54 PM
I am not explicitly setting an overlay, I'll have to check when I get home. The thing is, none of my nav bars are blue or have that title.

Shawnpk
Apr 30, 2011, 10:35 PM
It looks like your modalViewController is sitting behind the rootViewController. The rootViewController is usually the first view shown on the screen, which in this case looks like a navigation controller.

amagic84
May 1, 2011, 01:00 AM
Shawnpk, you're totally right! But now I don't understand how to fix it. My root view controller is a navigation controller with a hidden navigation bar. So I do not know why I'm seeing part of that bar over the modalViewController.

Any hints on how to fix it?

amagic84
May 1, 2011, 01:39 AM
Turns out my root view controller (UINavigationController) is overlapping the modalViewController (image picker). Any ideas on how to fix this?

Shawnpk
May 1, 2011, 09:17 AM
Turns out my root view controller (UINavigationController) is overlapping the modalViewController (image picker). Any ideas on how to fix this?

Look at the order of objects in Interface Builder. Is the rootViewController on top of the modalViewController?

amagic84
May 1, 2011, 11:33 AM
No, it wasn't. But the weirdest thing happened last night - the issue fixed itself.
Here's what I did:
I messed around with my code trying to present imagePicker with all of my different view controllers. I somehow got my code into an unusable state (the app would no longer start up) so I ended up erasing the app from my phone and reverting to the last snapshot of the code. Now that snapshot still had the problem as far as I knew. But then when I built the code and ran it on my iPhone the problem was no longer occurring. ImagePicker was covering up the whole screen all of a sudden. I'm no longer able to reproduce the problem, even with the code I posted.

So I'm happy its fixed but I'm bummed about now knowing how or why.

Thanks for all your help!

PhoneyDeveloper
May 1, 2011, 12:15 PM
Xcode definitely has a problem with deleting old resource files. We've all run into a case of weirdness that was fixed by a clean and rebuild.

Shawnpk
May 1, 2011, 12:27 PM
Xcode definitely has a problem with deleting old resource files. We've all run into a case of weirdness that was fixed by a clean and rebuild.

I usually clean my project anytime I make changes. It's very frustrating to make a change and see nothing.