UISegment Control in UITableView

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.

Answers


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 == 0 then array1 if == 1 then array2 and if == 2 then array3.

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 IBOutlet for tableView and use that IBOutlet to change the data using [tableView reloadData]; here tableView is IBOutlet for table view.

Happy Coding :)


Need Your Help

Javascript: give a variable a name made of 2 variables

javascript

I want to create a new variable in javascript but it's name should made of a stale part and a variable one like this:

Centering the clicked item in listview in Android

android listview center

I have a list view in left of the screen and on click of the item i want to update a text on the right half of the screen, what i want to do here is that to move the clicked item in center of the

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.