Sohan
Sohan

Reputation: 1287

buttons in a table header to load tdifferent table views

What's the best way for me to add 2 custom buttons in the header of my UITableView? On clicking either of those buttons, a different table View is loaded.

Thanks for the help!

Upvotes: 0

Views: 717

Answers (4)

Jhaliya - Praveen Sharma
Jhaliya - Praveen Sharma

Reputation: 31720

Use a separate UView and add both UIButton as subview into.

Then add this button's view in the parent view of your UITableView

Then both the button's view and UITableView will be the sibling view....

Upvotes: 0

lithium
lithium

Reputation: 995

UISegmentedControl is pretty much for this purpose, then you can hook the events and switch the views accordingly... It looks better tan two separate buttons, and also better from the user experience perspective...

Second choice is to have two different tables or one table with two different data. I would prefer two tables, each having its own data, and delegates. Easier to write cell rendering code and all...

If both data are of the same type like "Array of MyObject", then you can come away with just a flag and some ( flag ? firstDataArray : secondDataArray) type of selections in the table delegate methods.

Upvotes: 1

Chetan Bhalara
Chetan Bhalara

Reputation: 10344

First add two different customs button and then add two different table Views bellow that custom buttons.

Upvotes: 0

Joetjah
Joetjah

Reputation: 6132

Add the two buttons to the header, and use the IBActions of those buttons each to set the datasource to an other array. After that, use [tableView reloadData];

If you want to use buttons above the table, I'd suggest either using sections if your having no sections in your original table, or placing a toolbar above your table.

Upvotes: 1

Related Questions