【发布时间】:2011-07-04 00:56:51
【问题描述】:
我有一个标签栏应用程序。其中一个选项卡有一个导航堆栈。我想以编程方式更改选项卡,然后将新控制器推送到选定的选项卡堆栈上。我可以很好地更改标签:
KidScienceAppDelegate *appDelegate = (KidScienceAppDelegate*) [[UIApplication sharedApplication] delegate];
UITabBarController *tab=[appDelegate tabBarController] ;
tab.selectedIndex=2;
如果我只是运行它,它会正确移动到带有导航堆栈的选项卡并显示根视图。然后我想将一个新控制器推送到该堆栈上。我试过这个:
ExperimentsNameViewController *detailViewController = [[ExperimentsNameViewController alloc] initWithNibName:@"ExperimentsNameView" bundle:nil];
FindViewController *c = [tab.viewControllers objectAtIndex:2];
[c.navigationController pushViewController:detailViewController animated:NO];
但这不会推动控制器。有人有什么想法吗?
【问题讨论】: