[英]Swift: Add segmented controller to a navigation bar, and keep the title + nav buttons
I'd like to add a segmented controller to a navigation bar, below the title. 我想在标题下方的导航栏中添加分段控制器。
At the moment, I've got a storyboard UITableViewController with a CoreData-sourced dynamic table, embedded in a UINavigationController. 目前,我有一个故事板UITableViewController,其中包含一个基于CoreData的动态表,并嵌入在UINavigationController中。 I'd like the UISegmentedController to differentiate the sorting of the table.
我想要UISegmentedController区分表的排序。
There seems to be obj-C solutions available stackoverflow.com/questions/29480433/ and stackoverflow.com/questions/18813563 , but I'm looking for a Swift solution, that resembles the native apps. 似乎有可用的obj-C解决方案stackoverflow.com/questions/29480433/和stackoverflow.com/questions/18813563 ,但我正在寻找一种类似于本机应用程序的Swift解决方案。 I've also tried putting the segmented controller into a table cell with little success (can't get the action recognised).
我还尝试将分段控制器放入表单元中,但收效甚微(无法识别动作)。 I'd prefer not to abandon the table view controller.
我不想放弃表视图控制器。
Any suggestions? 有什么建议么?
I replaced the UITableViewController with a UIViewController and UITableView, then added the UISegmentedController to a UIToolBar positioned below the UINavigationBar. 我用UIViewController和UITableView替换了UITableViewController,然后将UISegmentedController添加到位于UINavigationBar下方的UIToolBar中。
I used removeShadow for the navbar, then clipsToBounds for the toolbar. 我将removeShadow用于导航栏,然后将clipsToBounds用于工具栏。 I also added another View to simulate the bottom shadow on the toolbar (because I couldn't get the toolbar shadow/background position function to work).
我还添加了另一个视图来模拟工具栏上的底部阴影(因为我无法使工具栏阴影/背景位置功能正常工作)。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.