我以编程方式在UITableView单元内创建UIBarbUttonItem:
func setupChildrenPicker(){
let chooseButton = UIBarButtonItem(title: Wordings.BTN_CHOOSE, style: UIBarButtonItemStyle.done, target: nil, action: #selector(self.pickerChildrenDonePressed))
}
func pickerChildrenDonePressed(){
print ("pickerChildrenDonePressed")
}
override func awakeFromNib() {
super.awakeFromNib()
setupChildrenPicker()
}
但是当我单击该BarButtonItem时,它没有调用pickerChildrenDonePressed()函数(未创建日志pickerChildrenDonePressed)。
将其命名为pickerChildrenDonePressed的正确代码是什么?
答案 0 :(得分:0)
使用此:
内部
UIBarButtonItem(title: Wordings.BTN_CHOOSE, style:UIBarButtonItemStyle.done, target: nil, action: #selector(self.pickerChildrenDonePressed)
将目标更改为self
,而不是 nil