问题
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:

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?
回答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
.
来源:https://stackoverflow.com/questions/2673714/how-to-put-a-uisegmentedcontrol-under-a-navigationcontroller