0

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!

4 Answers 4

1

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.

3
  • @kingthong: yes you can, but only it's title (text). For custom buttons in the header, you need a custom tableView. Or, the standard view with only 1 section, or a toolbar above your table.
    – Joetjah
    Apr 26, 2011 at 9:49
  • 1
    You can add drag and drop a UIView onto the UITableView component. This makes the view table's header. Then you can add whatever you like inside that single UIView...
    – lithium
    Apr 26, 2011 at 9:53
  • @lithium Thats a superb tip. Thanks to you and @Joetjah
    – Sohan
    Apr 26, 2011 at 10:30
1

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.

0

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

0

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....

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.