2

I was wondering what the best approach in order to have a UISegmentedControl appears just under the a navigationController just like in the AppStore application:

example image

The content I what to put in the different views are UITableView just like the AppStore app.

What I was thinking so far was:

  • a viewController with the UIToolbar with UISegmentedController
  • in this ViewController attaching my UITableViews

But what I can't figure out, is how to structure my controller source code files.

Do you have best practice, working examples or at least advices?

JosephH
  • 37,173
  • 19
  • 130
  • 154
jchatard
  • 1,881
  • 2
  • 20
  • 25

1 Answers1

1

I would use UITableView's tableHeaderView property for that. That way it will scroll together with the table view's contents.

To prevent the bar from scrolling together with the table content, I would make it a sibling view (relative to UITableView) and place it just above the table view. If you choose this approach you will have the following view hierarchy: controller's view holds the toolbar and the table view. Note that you will have to set up the table view and handle row deselection in -viewWillAppear: yourself, duplicating functionality of UITableViewController.

iBug
  • 2,334
  • 3
  • 32
  • 65
Costique
  • 23,712
  • 4
  • 76
  • 79
  • I just gave it a try, but as soon as you scroll the tableView down, the toolbar disappears, and this is not the behaviour I want. I really would like to have the toolbar always visible. – jchatard Apr 20 '10 at 09:03
  • Sorry, I didn't realize you want the bar to remain static. I updated my answer. – Costique Apr 20 '10 at 10:44