I am Root.
I am Root.

Reputation: 131

UINavigationController won't push other view controllers?

So I created a UINavigationController in my app's delegate and initialized it with my RootViewController instance. The UINavigationController was added as a subview of the app's UIWindow. (My RVC has a custom initializer if that matters.)

    - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
              _window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];

              _viewController = [[RootViewController alloc] initWithPath:@"/private/var/mobile/"];
              _viewController.title = @"mobile";

              UINavigationController *nav1 = [[[UINavigationController alloc] initWithRootViewController:_viewController] autorelease];

              //This part I'm not sure about as well
              [_window addSubview:nav1.view];
              [_window makeKeyAndVisible];

    return 0;
    }

With that information, I'm trying to push another instance of RVC onto the Navigation Stack from an UITableView like so:

    - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
              //I've tried it without the if statement as well
              if(indexPath.section == 0){
                      RootViewController *detailView = [[RootViewController alloc] initWithPath:launchDirectory];
                      detailView.title = relativeDirectory;
                      [self.navigationController pushViewController:detailView animated:YES];

As another note, my RVC tableview's datasource and delegate have been set to "self".

My question is: Why does the view stay the same even though I select a row on the table? The table doesn't push to a new one and I still see the same cell contents after selecting a row. In other words, nothing happens...

Thanks for any help.

Upvotes: 0

Views: 786

Answers (1)

CodaFi
CodaFi

Reputation: 43330

Your navigation controller is likely nil, which means that your -autorelease is a little too much. Typically, Navigation Controllers persist until the dealloc method of the delegate is called, so release it there.

Upvotes: 2

Related Questions