我想将分段 Controller 添加到标题下方的导航栏。
目前,我有一个 Storyboard UITableViewController,其中包含一个源自 CoreData 的动态表,嵌入在 UINavigationController 中。我希望 UISegmentedController 能够区分表格的排序。
似乎有可用的 obj-C 解决方案 stackoverflow.com/questions/29480433/和 stackoverflow.com/questions/18813563 ,但我正在寻找一个类似于 native 应用程序的 Swift 解决方案。我还尝试将分段 Controller 放入表格单元格中,但收效甚微(无法识别操作)。我不想放弃 TableView Controller 。
有什么建议吗?
最佳答案
我用 UIViewController 和 UITableView 替换了 UITableViewController,然后将 UISegmentedController 添加到位于 UINavigationBar 下方的 UIToolBar。
我使用removeShadow作为导航栏,然后使用clipsToBounds作为工具栏。我还添加了另一个 View 来模拟工具栏上的底部阴影(因为我无法使工具栏阴影/背景位置功能起作用)。
关于ios - Swift:将分段 Controller 添加到导航栏,并保留标题+导航按钮,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30884038/