20 Pixel Gap at top of view

Discussion in 'iOS Programming' started by isthisonetaken, Mar 17, 2012.

  1. isthisonetaken macrumors regular

    Joined:
    Jun 29, 2006
    #1
    Hey Guys,

    I'm trying to create a settings screen for my iPad app. The user taps the settings button and a modal form comes up. I put two views on the form (a skinny one on the left for the settings, a wider one on the right for the details). What I want is for the left view to have a table view, when the user selects a row, the details for that row are loaded in to the detail view...

    I'm using iOS 5 and Xcode 4.3. I used a static table view controller for the left view, got it loaded in as a child view and used a delegate to tell the parent which row the user taps. It's in this method that I'm having problems.

    I have another table view controller for the first settings I want the user to be able to change. It's a simple table view, but I need a navigation bar at the top so they can have add and edit buttons.

    This is how I load it:
    Code:
    RatesTableViewController *ratesTVC = [storyboard instantiateViewControllerWithIdentifier:@"Rates Table View Controller"];
            ratesTVC.managedObjectContext = self.managedObjectContext;
            ratesTVC.view.frame = self.detailView.bounds;
            /*
            [self.detailView addSubview:ratesTVC.view];
            [ratesTVC didMoveToParentViewController:self];
            [self addChildViewController:ratesTVC];
             */
            UINavigationController *navController = [[UINavigationController alloc] initWithRootViewController:ratesTVC];
            
            [self.detailView addSubview:navController.view];
            [ratesTVC didMoveToParentViewController:self];
            [self addChildViewController:navController];
    If I run the app and choose the first row, it loads the table view with a navigation bar, but with 2 major flaws:
    1) There is a 20 pixel gap (from my googling around, it has something to do with the status bar). In my storyboard, the modal form has its status bar set to none and the table view controller has its status bar set to none.
    2) Only the edit button is visible, the title and add buttons are not, almost as off the nab bar keeps going...

    If I comment out the UINavigationController stuff and uncomment the lines that are commented right now, then the table view controller fills the view properly, width and height wise, but then I have no way to add or edit items...

    Any ideas what's going on? This is making me pull my hair out!
     
  2. jnoxx macrumors 65816

    jnoxx

    Joined:
    Dec 29, 2010
    Location:
    Aartselaar // Antwerp // Belgium
    #2
    About the 20 pixel line, exactly, it should be the status bar.
    The bar with the battery percentage and time. That's 20 pixels.
    So either you turned it off, and your NIB's/Storyboards take it into account, which explains the missing 20 pixels.
     
  3. isthisonetaken thread starter macrumors regular

    Joined:
    Jun 29, 2006
    #3
    But the views/ subviews are all happening in a modal view controller. If I don't embed my table view controller in a UINavigationController, the table view takes up the entire child view like I expect it to. Once I embed the table view controller into a UINavigationController, and add the Navigation controller as the child view, that's when the 20 pixel gap happens...
     
  4. jnoxx macrumors 65816

    jnoxx

    Joined:
    Dec 29, 2010
    Location:
    Aartselaar // Antwerp // Belgium
    #4
    have u logged the Frame of your view? (or bounds), and of your subview that you add?
    I think that should reveal something :)
     

Share This Page