UINavigationController没有推送

时间:2013-10-12 18:45:12

标签: objective-c uitableview uinavigationcontroller pushviewcontroller

我在UITableViews中嵌入了两个UINavigationController。在第一个表viewcontroller中选择一个单元格应该触发推送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会正确显示。
  • 我尝试在nil的sender参数中使用selfperformSegueWithIdentifier:,结果相同。
  • 我已将第二个视图控制器转换为具有相同结果的香草UIViewController
  • “more”segue已正确标记并连接为push
  • 没有崩溃,只是缺乏segue。
  • 我已删除了故事板中的整个UINavigationController设置,并将其替换为相同的结果。
  • UINavigationController
  • 单独的.h / .m
  • 表视图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;
}

1 个答案:

答案 0 :(得分:0)

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

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

      

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

  •