UINavigationController popped/pushed problem

Discussion in 'iOS Development' started by masaj, May 21, 2009.

  1. masaj

    masaj New Member

    Joined:
    Apr 27, 2009
    Messages:
    13
    Likes Received:
    0
    I have a UITabBarController with 4 UINavigationController
    Each UINavigationController pushes a UITableViewController from it's viewDidLoad() method.
    (Similar to this example here
    http://dblog.com.au/iphone-developm...-the-uitabbar-and-uitableview-with-delegates/)

    It looks like this:

    Please Register or Log in to view images



    So the UINavigationController for the "Bar" tab pushes a BarUITableViewController which creates the table we see above.

    I then navigate to "Baz", which pushes it's own table, I select a row (in this example "Sample 1" is the row selected.) and this selection causes data to be loaded which needs to be rendered in the "Bar" tab.

    Please Register or Log in to view images



    So I load the data and recreate the BarUITableViewController as follows:
    Code:
                // barParent is the UINavigationController for the "Bar' tab.
                [barParent popViewControllerAnimated:NO]; // Should pop the old TableViewController
                BarUITableViewController *barViewController =
                    [[BarUITableViewController alloc] init];
                [barParent
                        pushViewController:barViewController animated:NO];
                [barViewController release];
    
    This is the exact same code which loaded the table originally from the UINavigationController's viewDidLoad() method seen in the first image above, except it's running in BazUITableViewController's didSelectRowAtIndexPath method. But now when I navigate to the "Bar" view, I see some strange artifact, a blank area roughly(?) the height of the tab bar or navigation bar. Does anyone know what would cause this or where I should dig further to find out?

    Please Register or Log in to view images

  2. gojohnnyboi

    gojohnnyboi Well-Known Member

    Joined:
    Jan 25, 2008
    Messages:
    3,339
    Likes Received:
    55
    I don't have time to read and reply now(I may later), but just for future reference, hold the home button on your iPod while you tap the sleep button at the top, and a screenshot will be taken and placed in your photo library, where you can grab it.
  3. masaj

    masaj New Member

    Joined:
    Apr 27, 2009
    Messages:
    13
    Likes Received:
    0
    EDIT think I found my answer. Apparently, even though I specify the same CGRect size for my table's initWithFrame, somehow this renders differently when created in a UINavigationController's viewDidLoad() context as opposed to a UINavigationController's viewDIdAppear(). Not sure why that is.

    I've removed the [[BarUITableViewController alloc] init] creation code from the UINavigationController's viewDidLoad() and removed it from the BazUITableViewController's didSelectRowAtIndexPath(). I simply create a fresh one each time in UINavigationController's viewWillAppear(). Doing this seems to fix the inconsistent CGRect size rendering issue.
    ------------------double post merged------------------
    Thanks gojohnny. I'll try that in the future.

    I think I found a workaround but I'm still curious as to why this is happening.

    Suspect this has something to do with UINavigationController's viewDidLoad() method being called before the NavigationBar is in the view? Hence coming from the path where it's already loaded I need to specify a larger table size? This CGRect initWithFrame stuff confuses me at times.
  4. NolesFans

    NolesFans New Member

    Joined:
    Sep 23, 2008
    Messages:
    404
    Likes Received:
    0
    Device:
    iPod touch
    viewDidLoad - Called after the controller’s view is loaded into memory.
    viewDidAppear - Sent to the controller after the view fully appears on screen.

    it is from the docs.
  5. SkylarEC

    SkylarEC Super Moderator Emeritus Staff Member

    Joined:
    Sep 19, 2007
    Messages:
    6,642
    Likes Received:
    129
    UIViewAutoResizingMasks ftw.
  6. sKeLeTr0n

    sKeLeTr0n New Member

    Joined:
    Mar 9, 2008
    Messages:
    10
    Likes Received:
    0
    Device:
    iPod touch
    How do you have done this Table in the "Bar" Section off your app? This is not a standard UI Element right?

Share This Page