这是我的代码:
override func viewDidLoad() {
super.viewDidLoad()
let addButton = UIBarButtonItem(barButtonSystemItem: .action
, target: self, action: #selector(tapButton))
let addButton1 = UIBarButtonItem(barButtonSystemItem: .add
, target: self, action: #selector(tapButton1))
navigationItem.rightBarButtonItem = [addButton,addButton1]
}
@IBAction func tapButton(_ sender: Any){
print("your tap")
let shareText = "share to others"
let activityViewController = UIActivityViewController(activityItems: [shareText], applicationActivities: nil)
present(activityViewController, animated: true, completion: nil)
}
@IBAction func tapButton1(_ sender: Any){
print("your tap1")
}
我搞错了
无法将类型'[uibarbuttonem]'的值赋给类型
“乌巴布托石?”在这行中“navigationItem.rightbabuttonem=
[添加按钮,添加按钮1]
怎么了?
最佳答案
把它改成
navigationItem.rightBarButtonItems = [addButton,addButton1]
关于ios - 在导航栏右侧添加两个按钮时出现错误,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/53719281/