How to put a UISegmentedControl under a NavigationController?(如何将 UISegmentedControl 放在 NavigationController 下?)
问题描述
我想知道让 UISegmentedControl 出现在 navigationController 下方的最佳方法是什么,就像在 AppStore 应用程序中一样:
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:
我要放在不同视图中的内容是 UITableView,就像 AppStore 应用一样.
The content I what to put in the different views are UITableView just like the AppStore app.
到目前为止我的想法是:
What I was thinking so far was:
- 带有 UIToolbar 的 viewControllerUISegmentedController
- 在这个 ViewController 中附加我的 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?
推荐答案
我会使用 UITableView 的 tableHeaderView 属性.这样它将与表格视图的内容一起滚动.
I would use UITableView's tableHeaderView property for that. That way it will scroll together with the table view's contents.
为了防止栏与表格内容一起滚动,我会将其设为兄弟视图(相对于 UITableView)并将其放置在表格视图的上方.如果您选择这种方法,您将拥有以下视图层次结构:控制器的视图包含工具栏和表格视图.请注意,您必须自己设置表格视图并在 -viewWillAppear: 中处理行取消选择,复制 UITableViewController 的功能.
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.
这篇关于如何将 UISegmentedControl 放在 NavigationController 下?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:如何将 UISegmentedControl 放在 NavigationController 下?
基础教程推荐
- libGDX 从精灵或纹理中获取像素颜色 2022-01-01
- AdMob 广告未在模拟器中显示 2022-01-01
- 如何从 logcat 中删除旧数据? 2022-01-01
- NSString intValue 不能用于检索电话号码 2022-01-01
- iPhone - 获取给定地点/时区的当前日期和时间并将其与同一地点的另一个日期/时间进行比较的正确方法 2022-01-01
- Android:getLastKnownLocation(LocationManager.NETWORK_PROVIDER 2022-01-01
- 通过重定向链接在 Google Play 中打开应用 2022-01-01
- Cocos2d iPhone 非矩形精灵触摸检测 2022-01-01
- iOS4 创建后台定时器 2022-01-01
- navigator.geolocation.getCurrentPosition 在 Android 浏览器上 2022-01-01
