Добрый день.
Подскажите, как узнать номер секции по которой происходит клик в tableView?
В настоящий момент есть такой код
func tableView(_ tableView: UITableView, viewForHeaderInSection section: Int) -> UIView? {
let header = tableView.dequeueReusableCell(withIdentifier: "headerCell") as! HeaderCell
let tapRecognizer = UITapGestureRecognizer(target: self, action: #selector(showAllWorkersInProject))
header.addGestureRecognizer(tapRecognizer)
header.projectNameLabel.text = projectsName[section]
return header
}
@objc func showAllWorkersInProject(){
print("tapSection")
if let indexPath = tableView.indexPathForSelectedRow {
print("tapSection \(section)")
showDetailProjectId = String(indexPath.section)
performSegue(withIdentifier: "DetailProjectSegue", sender: nil)
}
}
Первый принт tapSection отрабатывает нормально, а вот второй нет, что собс-но и логично по идее, т.к. клик происходит по header а не по ячейке.
Вопрос - как узнать номер секции того header, на который тапнули?