作者热门文章
- android - RelativeLayout 背景可绘制重叠内容
- android - 如何链接 cpufeatures lib 以获取 native android 库?
- java - OnItemClickListener 不起作用,但 OnLongItemClickListener 在自定义 ListView 中起作用
- java - Android 文件转字符串
我有一个 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 来做到这一点,但它不起作用。
我只能看到屏幕底部的工具栏,但没有任何按钮。
最佳答案
self.navigationController?.toolbarHidden = false
var items = [UIBarButtonItem]()
items.append(
UIBarButtonItem(barButtonSystemItem: .Plain, target: self, action: nil))
items.append(
UIBarButtonItem(barButtonSystemItem: .Add, target: self, action: "onClickedToolbeltButton:"))
self.setToolbarItems(barButtonItems, animated: true)
这必须按照写给 here 的答案为您工作.
关于ios - 为什么设置 barItems 不起作用?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37481063/
我有一个 UIViewController,我将它嵌入到 UINavigationController 中。 我想在工具栏中显示一个项目(对于工具栏,我的意思是 this : 这是我在 viewDid
在下图中,我在导航栏中有一个“后退”按钮,我希望它关闭“条形码扫描器”选项卡并将我带到点击“后退按钮”之前的 View 。如何这可能吗? 最佳答案 您的请求是不正确的 UI。选项卡不应包含用于转到上一
我是一名优秀的程序员,十分优秀!