我正在构建一个应用程序,它的委托(delegate)有一个 UINavigationController (navigationController)。第一个 View 是一个 UITabViewController (tabView),它有一个 UINavigationController,一个 UIViewController 和一个显示一些联系人的 UITableView。
我想要做的是在点击表格 View 中的联系人时(通过最顶部的 navController)推送一个带有联系人信息的新 View Controller
我在 appDelegate 中执行以下操作:
[self.window makeKeyAndVisible];
[self.window addSubview:[navigationController view]];
TabsView *tabsView = [[TabsView alloc] initWithNibName:nil bundle:nil];
[navigationController.view addSubview:[tabsView view]];
tabsView 的第一个选项卡加载 ContactsView.m,它有一个包含所有联系人的 UINavigationController,当有人点击一行时,它应该像这样推送新 View :
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
[table deselectRowAtIndexPath:indexPath animated:YES];
ContactSecondView * varContactSecondView = [[ContactSecondView alloc] initWithNibName:nil bundle:nil];
varContactSecondView.title = [[contactsArray objectAtIndex:indexPath.row] name];
[self.navigationController pushViewController:varContactSecondView animated:YES];
[varContactMapView release];
}
但是连续触摸没有任何反应。
所以我有不同的文件:Delegate with UINavigationController <- UITabViewController <- UIViewController with UINavigationController with UITableView;我想将 ViewController 插入第一个导航 Controller 。
应该如何访问委托(delegate)的导航 Controller ?我做得对吗?
编辑:如果这提供了任何线索,当我在 ContactsView.m 中执行 self.navigationController.title = @"Contacts";
时,它不会更改顶部栏的标题。
谢谢!
最佳答案
两件事。
不建议在导航 Controller 中嵌入
UITabBarController
。可以在UITabBarController
中嵌入 UINavigationController。我知道将您的UITabBarController
嵌入到UINavigationController
中是一件“很高兴”的事情,但您可能需要重新考虑您的设计,以便遵循 iOS 设计理念。不要将 subview 添加到您的 appDelegate 中的窗口,而是尝试将您正在使用的 Controller 添加到窗口的 rootViewController 属性中,即
self.window.rootViewController=navigationController;
关于ios - UINavigationController 与 UITabViewController,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7904967/