【问题标题】:UINavigationController not pushingUINavigationController 不推送
【发布时间】:2013-10-12 18:45:12
【问题描述】:

我在UINavigationController 中嵌入了两个UITableViews。在第一个 table viewcontroller 中选择一个单元格应该触发一个 push segue 到第二个。未执行此 segue。

FirstTableVC

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
   // getting called as planned
   if (indexPath.row == 0 && reload == YES) {
     // working
     [self pushedRefresh:self];
     reload = NO;
     return;
  }
  NSLog(@"past return"); // logged as planned
  // NOT performing!
  [self performSegueWithIdentifier:@"more" sender:[self.tableView cellForRowAtIndexPath:indexPath]];
}

我做了什么/注意到了

  • SecondTblVC's viewDidLoad: 方法未被调用。但是,如果我使用非推送 segue,VC 会正确显示。
  • 我尝试在performSegueWithIdentifier: 的发送者参数中使用nilself,结果相同。
  • 我已将第二个视图控制器转换为原版 UIViewController,结果相同。
  • “更多”转场正确标记并连接为push
  • 没有崩溃,只是缺少segue。
  • 我已删除情节提要中的整个 UINavigationController 设置,并将其替换为相同的结果。
  • 我确实没有有一个单独的.h/.m 用于UINavigationController
  • 表格视图delegates/data source 链接正在按计划工作。
  • 一个destinationViewController(通过登录performSegue方法得知)。

如果更多代码和屏幕截图有帮助,请告诉我。

谢谢。

编辑 这是我的cellForRowAtIndexPath 实现:

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath 

{
    static NSString *simpleTableIdentifier = @"ReuseCell";

    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:simpleTableIdentifier];

    cell.textLabel.text = [clubNames objectAtIndex:indexPath.row];
    cell.detailTextLabel.text = [times objectAtIndex:indexPath.row];

    if (cell == nil) 
    {
        cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:simpleTableIdentifier];
    }

    [cell setAccessoryType:UITableViewCellAccessoryDisclosureIndicator];

    return cell;
}

【问题讨论】:

  • 你是如何在故事板中创建转场的?
  • 从 UITableViewCell 拖到 SecondTblVC 并选择 push。
  • 好的,所以你根本不需要输入 [self performSegue...] 行。如果它是从 UITableViewCell 连接的,那么选择单元格无论如何都会调用 segue。只需删除该行。
  • 好的。已删除,但没有变化。
  • 我建议阅读 Ray wenderlich 网站上关于使用故事板的教程。它将引导您完成此操作。

标签: objective-c uitableview uinavigationcontroller pushviewcontroller


【解决方案1】:

尝试使用表格视图控制器而不是表格视图

  • 在您的故事板中,为每个 UITableViewControllers 创建一个故事板 ID,即:vc1 和 vc2
  • 在您的 vc1 函数中,查找第二个表视图控制器的情节提要 ID, 这是:

    UITableViewController *vc2 = [self.storyboard instanceViewControllerWithIdentifier:@"vc2"]; [self.navigationController pushViewController:vc2 动画:YES];

【讨论】:

  • 这个问题已经解决了。问题出在自定义 UiNavigationController 类上。您的建议已在项目符号 3 中描述。
猜你喜欢
  • 2012-09-15
  • 2019-12-14
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2012-04-18
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多