3
我有一個tableview有幾個部分。我想要的是當我從節中選擇一個特定的tableview單元格時,我想要該節的標題標題。我看了幾個SO問題,但沒有發現任何有用的東西。 在此先感謝。如何從選定的tableview單元格獲取標題部分標題?
我有一個tableview有幾個部分。我想要的是當我從節中選擇一個特定的tableview單元格時,我想要該節的標題標題。我看了幾個SO問題,但沒有發現任何有用的東西。 在此先感謝。如何從選定的tableview單元格獲取標題部分標題?
可以拿到冠軍與tableviewcell點擊方法如下代碼
UITableViewHeaderFooterView* header =[self.tableView headerViewForSection:indexPath.section];
NSLog(@"Header text = %@", header.textLabel.text);
在斯威夫特
let sectionHeaderView = table.headerViewForSection(indexPath.section)
let sectionTitle = sectionHeaderView?.textLabel?.text
嘗試以下獲得冠軍,如果您正在使用 「titleForHeaderInSection」 表委託:
func tableView(tableView: UITableView, didSelectRowAtIndexPath indexPath: NSIndexPath) {
let title = self.tableView(tableView, titleForHeaderInSection: indexPath.row)
}