开发者

UITableViewController detailView never pushed

开发者 https://www.devze.com 2023-01-11 05:06 出处:网络
I have a UITableViewController as one of 开发者_开发问答the view controllers on the second tab of my tab bar controller.

I have a UITableViewController as one of 开发者_开发问答the view controllers on the second tab of my tab bar controller.

In didSelectRowAtIndexPath i create a detail view controller, but it never gets pushed onto the navigation stack... and the app doesnt crash either, as i can NSLog after the call to pushViewController.

This is the method:

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
    KeyboardViewController *v = [[KeyboardViewController alloc] initWithNibName:@"KeyboardView" bundle:nil];
    [self.navigationController pushViewController:v animated:YES];
    NSLog(@"gets here OK"); 
}

What would cause this? Surely if navigationController didn't exist then it would crash? Since this is a UITableViewController, it should be created automatically should it not?

Thanks


Surely if navigationController didn't exist then it would crash?

No, [nil method] does not crash.

Since this is a UITableViewController, it should be created automatically should it not?

A UITableViewController does not have a UINavigationController by default. You have to put the UITableViewController inside a UINavigationController.

0

精彩评论

暂无评论...
验证码 换一张
取 消