ios - UINavigationController 与 UITabViewController

标签 ios uinavigationcontroller pushviewcontroller uitabview

我正在构建一个应用程序,它的委托(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"; 时,它不会更改顶部栏的标题。

谢谢!

最佳答案

两件事。

  1. 不建议在导航 Controller 中嵌入 UITabBarController。可以在 UITabBarController 中嵌入 UINavigationController。我知道将您的 UITabBarController 嵌入到 UINavigationController 中是一件“很高兴”的事情,但您可能需要重新考虑您的设计,以便遵循 iOS 设计理念。

  2. 不要将 subview 添加到您的 appDelegate 中的窗口,而是尝试将您正在使用的 Controller 添加到窗口的 rootViewController 属性中,即

    self.window.rootViewController=navigationController;

关于ios - UINavigationController 与 UITabViewController,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7904967/

相关文章:

ios - 如何防止 uitabbaritem 将我带到 "root" Controller ?

ios - UITextField文本在自定义单元格中重复

ios - 在 Swift 中记录行号和方法名

javascript - 内联 youtube 视频在 iOS 上的 cordova 应用程序中不起作用

ios - 使用导航 Controller 时关闭 View Controller 不起作用

ios - 选项卡单击应打开 slider 菜单 objective-c

ios - xcode 5 UITableView 总是填满屏幕的整个长度

iOS:如何在弹出 UIViewController 的子 UIViewController 后将其返回 "Refresh"?

ios - 使导航项的左侧栏按钮的标题与上一个 View 的标题相同

ios - pushViewController 做一个黑色 View