gpt4 book ai didi

swift - UIBarButtonItem 操作不起作用 UITableView 单元格

转载 作者:行者123 更新时间:2023-11-30 11:03:17 25 4
gpt4 key购买 nike

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

最佳答案

使用这个:

内部

UIBarButtonItem(标题:Wordings.BTN_CHOOSE,样式:UIBarButtonItemStyle.done,目标:nil,操作:#selector(self.pickerChildrenDonePressed)

目标更改为self而不是nil

关于swift - UIBarButtonItem 操作不起作用 UITableView 单元格,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53040005/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com