Search code examples
ipaduinavigationcontrollerdrawpushviewcontroller

pushViewController does not cause new controller to draw view


Preface: I am not using *.xib files.

I instantiate a UINavigationController in a class that effectively serves as my 'rootViewController'. This 'rootViewController' also has two UITableViewController members that are drawn on different sections of the iPad screen. One of which is set as the root view for the navigation controller. Let's call it tableViewControllerA.

The problem is, when I invoke pushViewController on a valid UINavigationController, I see no effect: [tableViewControllerA.navigationController pushViewController:tableViewControllerX animated:YES];

I've gathered from the posts I've searched today, that this push method should in turn cause the screen to redraw the top of stack controller.view. This is not what I'm seeing.

It seemed there was a disconnect in my implementation, and it was time to reference a working example in my environment (xcode 4.0). Assuming the canned templates would provide a working basis, I created a new navigation-based applications. I simply modified didFinishLaunchingWithOptions: as follows.

    UIViewController *view1 = [[UIViewController alloc] init];
    UIViewController *view2 = [[UIViewController alloc] init];

    view1.title = @"view1";
    view2.title = @"view2";

    [self.navigationController pushViewController:view1 animated:YES];
    [self.navigationController pushViewController:view2 animated:YES];

    self.window.rootViewController = [[UINavigationController alloc] initWithRootViewController:view1];

    [view1 release];
    [view2 release];

I found similar results. When I launch the simulator the screen title reads the title of whatever the self.window.rootViewController is pointing at. With the code as is, the title of the resulting top screen reads "view1". When I initWithRootViewController:view2, the resulting top screen reads "view2".

So please tell me I'm stupid cuz xyz... Thanks.


Solution

  • Here are some references and suggestions:

    Simple tutorial for navigation based application:

    http://humblecoder.blogspot.com/2009/04/iphone-tutorial-navigation-controller.html

    Here is another one to create the step by step navigation controller and adding the views:

    http://www.icodeblog.com/2008/08/03/iphone-programming-tutorial-transitioning-between-views/

    and here a bit advance with navigation + tab bar controller: http://developer.apple.com/library/ios/#featuredarticles/ViewControllerPGforiPhoneOS/CombiningToolbarandNavigationControllers/CombiningToolbarandNavigationControllers.html