Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/swift/16.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Swift UIBarButtonim操作不工作UITableView单元格_Swift_Uitableview_Uibarbuttonitem - Fatal编程技术网

Swift UIBarButtonim操作不工作UITableView单元格

Swift UIBarButtonim操作不工作UITableView单元格,swift,uitableview,uibarbuttonitem,Swift,Uitableview,Uibarbuttonitem,我在UITableView单元格中以编程方式创建UIBarButtonim,如下所示: func setupChildrenPicker(){ let chooseButton = UIBarButtonItem(title: Wordings.BTN_CHOOSE, style: UIBarButtonItemStyle.done, target: nil, action: #selector(self.pickerChildrenDonePressed)) } func picke

我在UITableView单元格中以编程方式创建UIBarButtonim,如下所示:

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()
}
但是当我点击这个按钮时,它并没有调用pickerchildrendepressed()函数(没有创建日志pickerchildrendepressed)

将其命名为PickerChildrenePressed的正确代码是什么?

使用以下代码:

里面

uibarbuttonite(标题:Wordings.BTN\u CHOOSE,样式:uibarbuttonimstyle.done,目标:nil,操作:#选择器(self.pickerchildrendepressed)

目标更改为
self
而不是nil

使用以下方法:

里面

uibarbuttonite(标题:Wordings.BTN\u CHOOSE,样式:uibarbuttonimstyle.done,目标:nil,操作:#选择器(self.pickerchildrendepressed)


target更改为
self
而不是nil

您应该共享更多可编译的代码来重现问题。是否有任何具体原因使用
uiBarButtonim
而不是
uiButtonim
?我认为除了导航栏、工具栏和选项卡栏之外,您不应该在其他位置使用
uiBarButtonim
。对于其他位置,请使用
UIButton
。您使用
UIBarButtonItem
而不是
UIButton
是否有特定原因,因为当我单击tableview单元格中的“自定义”按钮时,它将调用pickerView。而且pickerView是自定义的。UIBarButtonItem会在左上方和右上方创建,完成并取消。您可以吗UIButton替换该UIBarButtonim?在
UIBarButtonim中设置目标(标题:words.BTN_CHOOSE,样式:uiBarButtonimStyle.done,目标:nil,操作:#选择器(self.pickerChildren pressed)
将其改为self而不是nil@ShubhamBakshi,您的答案是正确的。谢谢。您应该共享更多可编译的代码来重现此问题。是否有任何具体原因使用
UIBarButtonItem
而不是
UIButton
?我认为除了导航栏、工具栏、选项卡B之外,您不应该在其他地方使用
UIBarButtonItem
ar.对于其他位置,请使用
UIButton
。您使用
UIBarButtonItem
而不是
UIButton
是否有特定原因,因为当我单击tableview单元格中的自定义按钮时,它将调用pickerView。并且pickerView是自定义的。UIBarButtonItem将在左上方和右上方创建,完成并取消。UIButton可以替换该UIBarButtonim吗?将
uiBarButtonim中的目标(标题:words.BTN\u CHOOSE,样式:uiBarButtonimStyle.done,目标:nil,操作:#选择器(self.pickerChildrendepressed)
设置为self而不是selfnil@ShubhamBakshi,你的答案是正确的。谢谢。