【发布时间】:2016-09-25 15:37:09
【问题描述】:
我有一个 UIViewController,我将它嵌入到 UINavigationController 中。
我想在工具栏中显示一项(工具栏是指this:
这是我在 viewDidLoad 方法中的代码
self.navigationController?.toolbarHidden = false
self.navigationController?.toolbar.items?.append(UIBarButtonItem(title: "Buy Potato", style: .Plain, target: self, action: #selector(ViewController.buyPotato)))
self.navigationController?.toolbarItems?.append(UIBarButtonItem(title: "Buy Potato", style: .Plain, target: self, action: #selector(ViewController.buyPotato)))
self.toolbarItems?.append(UIBarButtonItem(title: "Buy Potato", style: .Plain, target: self, action: #selector(ViewController.buyPotato)))
而且我已经有了buyPotato方法
func buyPotato() {
}
如您所见,我尝试使用 viewController 或 navigationController 来做到这一点,但它不起作用。
我只能看到屏幕底部的工具栏,但没有任何按钮。
【问题讨论】:
标签: ios swift uinavigationcontroller uitoolbar uitoolbaritem