3

我有两个UITableViews嵌入在一个UINavigationController. 在第一个 table viewcontroller 中选择一个单元格应该触发一个 push segue 到第二个。这个segue没有被执行。

第一表VC

- (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 会正确显示。
  • 我尝试在 sender 参数中使用niland以获得相同的结果。selfperformSegueWithIdentifier:
  • 我已将第二个视图控制器转换为UIViewController具有相同结果的香草。
  • “更多”segue被正确标记并连接为push
  • 没有崩溃,只是缺乏segue。
  • 我已经删除了情节提要中的整个UINavigationController设置,并用相同的结果替换了它。
  • 没有单独的 .h/.mUINavigationController
  • 表视图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;
}
4

1 回答 1

0

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

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

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

于 2013-11-25T06:33:21.783 回答