开发者

Why does this pushViewController not work?

开发者 https://www.devze.com 2023-03-27 17:53 出处:网络
I have a UIViewController class, which has a button which triggers this: DetailViewController *viewController = [[DetailViewController alloc] initWithNibName:@\"DetailViewController\" bundle:nil];

I have a UIViewController class, which has a button which triggers this:

DetailViewController *viewController = [[DetailViewController alloc] initWithNibName:@"DetailViewController" bundle:nil];
[s开发者_运维技巧elf.navigationController pushViewController:viewController animated:YES];
[viewController release];

Why does the push do nothing? If it matters, the UIViewController is within a UITabBarController.


My best guess for this in general is that you haven't yet created a UINavigationController. You need to create a UINavigationController first, then you can push onto the stack.

You can check for this by using the navigationController property to see whether the current viewController (self) is currently in a UINavigationController's hierarchy; if not , the navigationController property returns nil.


Because self.navigationController is nil? If you didn't create a UINavigationController to manage the contents of the current tab of your UITabBarController then you have nothing to push a new view controller onto.

0

精彩评论

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

关注公众号