我想将 UITableView 的部分标题推送到另一个 View Controller 的部分标题。 但是我想不出一种方法来阅读现有的章节标题。现有的章节标题是动态构建的,我宁愿重用它也不愿重新构建它。
if (indexPath.section == 0) {
SecondViewController *secondViewController = [[SecondViewController alloc] init];
secondViewController.strValueHolder = FOO_section.sectionTitle; // FOO Code
[[self navigationController] pushViewController:secondViewController animated:YES];
[secondViewController release];
}
最佳答案
可以直接调用titleForHeaderInSection方法:
NSString *sectionTitle =
[self tableView:tableView titleForHeaderInSection:indexPath.section];
或将您当前在 titleForHeaderInSection 中的代码移动到自定义方法,并从 titleForHeaderInSection 和您推送另一个 View Controller 的位置调用该自定义方法。
关于xcode - 读取 UITableView Section Title 的字符串值,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5435680/