导航控制器无法推送视图控制器

3
我有两个UITableView嵌入在一个UINavigationController中。在第一个表视图控制器中选择单元格应该会触发推送转换到第二个表视图控制器,但是这种转换没有被执行。 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]];
}
我所做的/注意到的事情
  • SecondTblVCviewDidLoad:方法没有被调用。但是,如果我使用非推送segue,视图控制器会正确地呈现。
  • 我尝试在performSegueWithIdentifier:方法的sender参数中使用nilself,但结果相同。
  • 我将第二个视图控制器转换为普通的UIViewController,结果相同。
  • "更多"segue标签正确连接并标记为push
  • 没有崩溃,只是缺少segue。
  • 我删除了故事板中的整个UINavigationController设置,并以相同的结果替换它。
  • 我没有为UINavigationController创建单独的.h/.m文件
  • 表格视图delegates/data source链接按计划工作。
  • performSegue方法中记录学习到了destinationViewController

如果需要更多的代码和截图,请告诉我。

谢谢。

编辑 这是我的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;
}

你是如何在故事板中创建segue的? - Fogmeister
好的。已删除,但没有更改。 - eulr
我建议阅读 Ray Wenderlich 网站上关于使用故事板的教程。它会指导你完成这个过程。 - Fogmeister
cellForRowAtIndexPath 中创建的单元格是否具有在故事板中指定的原型单元格相同的标识符? - Mike S
如果标识符匹配,您可以尝试发布故事板的屏幕截图以获得帮助。 - Mike S
显示剩余3条评论
1个回答

0

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

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

UITableViewController *vc2 = [self.storyboard instantiateViewControllerWithIdentifier:@"vc2"]; [self.navigationController pushViewController:vc2 animated:YES];


问题已经解决。问题出在自定义的UiNavigationController类上。您的建议在第三点中被说明。 - eulr

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接