I have added a segment control to my table view and what my problem/question is I need to display text in tableview cells based on segment selected.
I have followed some tutorials, in that they gave me text in labels based on segment selected. I used segmentControl.selectedIndexPath also. So can anyone tell me how can we set that array of objects to my tableview cells based on segment selected?
Correct me if any mistakes in my english.
Please help me.
Thanks a lot for help.
First of all you have to divide your data in different arrays depends on your requirement ie Number of segmentControl.
Here if there are three segment controls then create three array an in the table view’s delegate methods depending on segment control’s selected index change the array to display in table view.
Like if
segmentControl.selectedIndex == 0thenarray1if== 1thenarray2and if== 2thenarray3.In all delegate and datasource methods of table view. And on segment control’s selecedIndexChange: method call reload table.
Happy Coding 🙂
EDIT 1
For change data in table view on segmented control’s index change you must have one
IBOutletfor tableView and use thatIBOutletto change the data using[tableView reloadData];heretableViewisIBOutletfor table view.Happy Coding 🙂