How to put a UISegmentedControl under a NavigationController?

…衆ロ難τιáo~ 提交于 2019-12-19 10:35:27

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!