UINavigationBar和UITableView之间的ToolBar? [英] ToolBar between UINavigationBar and UITableView?
问题描述
我在UINavigationController上嵌入了一个UITableViewController。此tableView是NSFetchedResultsController的一个实例。
我需要在NavigationController的顶栏和TableViewController之间添加一个工具栏,但我无法弄明白该怎么做(我甚至不知道它是否可行)。
我想做一些类似Apple用WWDC App做的事情(除了他们没有嵌入在NavigationController中的TableViewController)。
我需要在栏上设置一些控制来驱动NSFetchedResultsController。
I have a UITableViewController embedded on a UINavigationController. This tableView is an instance of NSFetchedResultsController. I need to add a Toolbar between the NavigationController's top bar and the TableViewController, but I can't figure out how to do it (I don't even know if it's possible). I want to do something like Apple did with their WWDC App (except that they don't have the TableViewController embedded in the NavigationController). I need to have some controls on the bar to drive the NSFetchedResultsController.
有些人建议那些类似问题的人使用UITableView而不是TVC,但我需要将TVC作为NSFetchedResultsController的一个实例。
Some people suggested to people with similar problems to use a UITableView instead of a TVC, but I do need to have a TVC as an instance of NSFetchedResultsController.
关于如何实现这一点的任何想法?
我是否必须以编程方式执行此操作?如果是这样,怎么样?
Any ideas on how to accomplish this? Would I have to do it programmatically? If so, how?
顺便说一下,我用故事板和ARC瞄准iOS6 +。
Btw, I'm targeting iOS6+ with storyboards and ARC.
推荐答案
我更喜欢的方法是在外层使用 UIViewController
,其中包含工具栏和容纳表的容器视图。然后在单独的 UITableViewController
中构建表,并使用embed segue将其连接到容器视图中。总的来说,我认为这使代码更加模块化,更容易理解,因为故事板中列出了高级结构。
The approach I prefer is to use a UIViewController
at the outer level, containing your toolbar and a container view that holds the table. Then build your table in a separate UITableViewController
and wire it into the container view using an embed segue. Overall, I think this makes the code more modular and easier to follow because the high-level structure is laid out in the storyboard.
使用嵌入segue的步骤是如下所示:
The steps to use an embed segue are as follows:
- 按住Control键从容器视图拖动到要嵌入的视图控制器,然后选择嵌入选项。
- 在属性检查器中为嵌入segue指定一个标识符。
- 在父级的
prepareForSegue $ c中配置表视图控制器$ c>方法,检查你的segue的标识符。
- Control-drag from the container view to the view controller you want to embed and select the "Embed" option.
- Give the embed segue an identifier in the attributes inspector.
- Configure the table view controller in the parent's
prepareForSegue
method, checking for your segue's identifier.
在我的VCollectionViewGridLayout 库。看看Sort& amp;过滤示例项目。
There is an example of this in my VCollectionViewGridLayout library. Take a look at the Sort & Filter example project.
这篇关于UINavigationBar和UITableView之间的ToolBar?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!