UIImagePickerController overlapped by status bar screen area

Discussion in 'iOS Programming' started by amagic84, Apr 29, 2011.

  1. amagic84
    Expand Collapse
    macrumors newbie

    Joined:
    Apr 29, 2011
    #1
    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
     
  2. balamw
    Expand Collapse
    Moderator

    balamw

    Staff Member

    Joined:
    Aug 16, 2005
    Location:
    New England
  3. amagic84
    Expand Collapse
    thread starter macrumors newbie

    Joined:
    Apr 29, 2011
    #3
    screenshot

    Sure, here's a screenshot: http://img543.imageshack.us/img543/2256/photohc.png

    Here's how I invoke presentation image picker:
    Code:
     
    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...
     
  4. amagic84
    Expand Collapse
    thread starter macrumors newbie

    Joined:
    Apr 29, 2011
    #4
    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.
     
  5. PhoneyDeveloper
    Expand Collapse
    macrumors 68030

    PhoneyDeveloper

    Joined:
    Sep 2, 2008
    #5
    I think you're also setting an overlayview. Is it possible that the navbar is on that overlay view?
     
  6. amagic84
    Expand Collapse
    thread starter macrumors newbie

    Joined:
    Apr 29, 2011
    #6
    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.
     
  7. Shawnpk
    Expand Collapse
    macrumors 6502

    Joined:
    Jan 13, 2011
    Location:
    Los Angeles, CA
    #7
    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.
     
  8. amagic84
    Expand Collapse
    thread starter macrumors newbie

    Joined:
    Apr 29, 2011
    #8
    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?
     
  9. amagic84
    Expand Collapse
    thread starter macrumors newbie

    Joined:
    Apr 29, 2011
    #9
    Turns out my root view controller (UINavigationController) is overlapping the modalViewController (image picker). Any ideas on how to fix this?
     
  10. Shawnpk
    Expand Collapse
    macrumors 6502

    Joined:
    Jan 13, 2011
    Location:
    Los Angeles, CA
    #10
    Look at the order of objects in Interface Builder. Is the rootViewController on top of the modalViewController?
     
  11. amagic84
    Expand Collapse
    thread starter macrumors newbie

    Joined:
    Apr 29, 2011
    #11
    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!
     
  12. PhoneyDeveloper
    Expand Collapse
    macrumors 68030

    PhoneyDeveloper

    Joined:
    Sep 2, 2008
    #12
    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.
     
  13. Shawnpk
    Expand Collapse
    macrumors 6502

    Joined:
    Jan 13, 2011
    Location:
    Los Angeles, CA
    #13
    I usually clean my project anytime I make changes. It's very frustrating to make a change and see nothing.
     

Share This Page