1

我正在构建一个代表具有 UINavigationController (navigationController) 的应用程序。第一个视图是一个 UITabViewController (tabView),它有一个 UINavigationController 和一个 UIViewController 和一个显示一些联系人的 UITableView。

我想要做的是在点击表格视图中的联系人(在最顶部的导航控制器上)时推送一个带有联系人信息的新视图控制器

我在 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,当有人点击一行时,它应该像这样推送新视图:

- (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];
}

但是连续触摸时没有任何反应。

所以我有不同的文件:使用 UINavigationController <- UITabViewController <- UIViewController 和 UINavigationController 和 UITableView 进行委托;我想将 ViewController 推入第一个导航控制器。

应该如何访问委托的 navigationController?我做对了吗?

编辑:如果这提供了任何线索,当我self.navigationController.title = @"Contacts";在 ContactsView.m 中这样做时,它不会更改顶栏的标题。

谢谢!

4

2 回答 2

0

我可能错了,但我认为您没有使用正确的方法在导航控制器中设置视图控制器。

你做 :

[navigationController.view addSubview:[tabsView view]];

我会使用:

[navigationController setViewControllers:[NSArray arrayWithObject:tabsView] animated:NO];
于 2011-10-26T15:34:44.680 回答
0

两件事情。

  1. 不建议UITabBarController在导航控制器中嵌入 a。可以将 UINavigationController 嵌入到UITabBarController. 我知道将你嵌入到 .js 中将是一个“很好的选择” UITabBarControllerUINavigationController但你可能需要重新考虑你的设计,以便遵循 iOS 设计理念。

  2. 不要将子视图添加到 appDelegate 中的窗口,而是尝试将您正在使用的控制器添加到窗口的 rootViewController 属性,即,

    self.window.rootViewController=导航控制器;

于 2011-10-26T16:37:38.540 回答