I have a tableview header within my table view that uses a custom cell with a segment control in it.
I have added a gesture recognizer to my storyboard:
@IBAction func swipeLeftTapped(_ sender: Any) {
}
I want to swipe left and decrease the selected segment of the segment control within that storyboard header by 1. How would I do that. Here is what I have tried but obviously it doesn't work.
let header = self.mainTableView.cellForRow(at: IndexPath(row: 0, section: 0)) as! HeaderTableViewCell
also
let header2 = self.mainTableView.headerView(forSection: 0) as! HeaderTableViewCell
header.productSegmentControl.selectedSegmentIndex += 1
Here is my code for the tableview header
func tableView(_ tableView: UITableView, viewForHeaderInSection section: Int) -> UIView? {
let cell = tableView.dequeueReusableCell(withIdentifier: "HeaderCell") as! HeaderTableViewCell
cell.productSegmentControl.selectedSegmentIndex = productIdIndex
return cell
}
How do you access a tableview header like you would a normal cell?