I have a UITableView with custom section headers, made via the storyboard using a custom prototype cell with a Identifier of "headerCell", along with a Cocoa Touch Class called "HeaderViewCell" subclassing UITableViewCell.
func tableView(_ tableView: UITableView, viewForHeaderInSection section: Int) -> UIView? {
let headerCell = tableView.dequeueReusableCell(withIdentifier: "headerCell") as! HeaderViewCell
headerCell.sectionTitle.text = viewModel.items[section].sectionTitle
headerCell.section = section
headerCell.delegate = self
return headerCell
}
The button in the cell fires a delegate func passing in the section that was assigned to it.
Everything works great- setting the title, tapping the button I needed, etc... EXCEPT that when you tap the blank space between the section title (on the left) and button (on the right), the section header highlights as if it's a cell in the section, and then performs the segue for the first row in the section.
Selection is set to "None" in the attributes inspector. If I toggle User Interaction Enabled, then the button does not work.
I've found lots of posts where people are trying to register taps on the section headers (answer: with tap gestures), but exhausted myself in search of how to block them. In the didSelectRow at delegate method, I see the same IndexPath I would as if I clicked on the row and not the header, so I can't block it from there.
Being that using a custom prototype cell is the most widely suggested response to a custom section header, I would have expected this to have been an issue for someone else as well. ?