使用Swift将工具栏添加到UITableViewController

Del*_*unt 3 swift ios8.3

我希望在tableview的底部添加一个工具栏.在这篇stackoverflow文章中,我了解到"如果您的UITableViewController嵌入在UINavigationController中,导航控制器会附带一个工具栏.您不需要添加自己的工具栏." 该帖子的作者继续列出Objective-c代码以使其可见.我可以指向一个教程或示例,它演示了同样的快速代码吗?我是iOS应用程序和Xcode的新手,在我去的时候学习它.

Dea*_*ean 5

要使工具栏可见,只需在viewDidLoad中使用此函数:

self.navigationController!.setToolbarHidden(false, animated: true)
Run Code Online (Sandbox Code Playgroud)

要填充项目,您有setToolbarItem函数:

self.navigationController!.setToolbarItems(<toolbarItems: [AnyObject]?>, animated: <Bool>)
Run Code Online (Sandbox Code Playgroud)

这是UINavigationController类引用的链接

  • 这有效,但我似乎无法向显示的工具栏添加任何按钮.有什么想法吗? (2认同)