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 Vie开发者_开发技巧w is loaded.
Thanks for the help!
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.
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.
First add two different customs button and then add two different table Views bellow that custom buttons.
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....
精彩评论