Reputation: 6740
I have a cell with a UISegmentedControl. This control is connected to the table view cell, and not my view controller. But I need to know which index is selected to populate the table view with correct array.
How do I access the segmented controller in the table view cell from the view controller?
Upvotes: 1
Views: 429
Reputation: 4050
There are many ways by which you can go about this, one way would be to use a protocol, define a protocol with a method such as didSelectCellSegmentedControl(segmentedControl: UISegmentedControl, selectedSegmentIndex index: Int)
. Then make your viewcontroller the delegate of the cell in cellForRowAtIndexPath delegate method
, conform to the didSelectCellSegmentedControl
protocol and handle the selection there.
Upvotes: 3