UIBarButtonItem操作不起作用UITableView单元格

时间:2018-10-29 06:38:35

标签: swift uitableview uibarbuttonitem

我以编程方式在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的正确代码是什么?

1 个答案:

答案 0 :(得分:0)

使用此:

内部

UIBarButtonItem(title: Wordings.BTN_CHOOSE, style:UIBarButtonItemStyle.done, target: nil, action: #selector(self.pickerChildrenDonePressed)

目标更改为self,而不是 nil