xcode - 读取 UITableView Section Title 的字符串值

标签 xcode uitableview sectionheader

我想将 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/

相关文章:

ios:uitableview 部分标题 anchor 到表顶部

ios - 将 xml 解析为 UITableView

ios - 为什么多次调用 UITableView numberOfRowsInSection?

ios - 在 iOS 项目中使用 bundle 时出错/如何创建正确的 bundle ?

ios - (Swift 3)我需要向用户发送通知以在特定时间打开应用程序。使用本地通知还是推送通知更好?

ios - 为什么 nib 文件中的 UITableViewCell(加载并添加到堆栈)在 viewDidAppear 中为零,但在 viewDidLoad 中没问题?

android - getPositionForSection 和 getSectionForPosition 的区别

xcode - 安装 iOS 4.2 和 4.2 SDK 后无法在设备上运行

ios - SwiftyJSON - 'inout JSON' 不可转换为 'JSON'