2

我想将 UITableView 的部分标题推送到另一个视图控制器的部分标题。但我想不出一种方法来阅读现有的章节标题。现有的部分标题是动态构建的,我宁愿重用它而不是再次重建它。

 if (indexPath.section == 0) {

      SecondViewController *secondViewController = [[SecondViewController alloc] init];
      secondViewController.strValueHolder = FOO_section.sectionTitle; // FOO Code
      [[self navigationController] pushViewController:secondViewController animated:YES];
      [secondViewController release];

 }
4

1 回答 1

8

可以直接调用 titleForHeaderInSection 方法:

NSString *sectionTitle = 
    [self tableView:tableView titleForHeaderInSection:indexPath.section];

或将您当前在 titleForHeaderInSection 中的代码移动到自定义方法,并从 titleForHeaderInSection 和您推送另一个视图控制器的位置调用该自定义方法。

于 2011-03-25T18:51:26.710 回答