I am trying to control my UITableView
based on the selectedSegmentIndex
of a UISegmentedControl
inside my UITableView header. Essentially, I want this UISegmentedControl
to work like Twitter's 'Me' tab. I have the UISegmentedControl
inside a UITableView
header and it is dequeued using this method:
override func tableView(_ tableView: UITableView, viewForHeaderInSection section: Int) -> UIView? {
let cell = tableView.dequeueReusableCell(withIdentifier: "sectionDetailsHeaderView") as! SectionDetailsHeaderTableViewCell
return cell
}
I have an outlet for the UISegmentedControl hooked up to SectionDetailsHeaderTableViewCell
, but I can't figure out how to detect a change in the UISegmentedControl. I want to set a variable, var segmentedControlValue = Int()
to the selectedSegmentIndex
every time the value changes and call a function, func chooseDataToDisplay() {}
when the value changes. How do I go about doing this?