iOS swift 3编码tableview编辑按钮使用UIButton而不是UIBarButton
我编写了以下代码。我试图使它的功能类似于iOS swift 3编码tableview编辑按钮使用UIButton而不是UIBarButton,ios,swift3,Ios,Swift3,我编写了以下代码。我试图使它的功能类似于UIBarButtonItemedit item函数,但使用UIButton,因为我有一个自定义导航栏,但我有几个编译错误。该功能应允许在按下按钮时进行编辑,并在再次按下时完成编辑 @IBAction func edit(sender: UIButton){ if [tableView.isEditing] == YES { [self.tableView .setEditing(false, animated: false)]
UIBarButtonItem
edit item函数,但使用UIButton
,因为我有一个自定义导航栏,但我有几个编译错误。该功能应允许在按下按钮时进行编辑,并在再次按下时完成编辑
@IBAction func edit(sender: UIButton){
if [tableView.isEditing] == YES {
[self.tableView .setEditing(false, animated: false)]
}
else{
[self.tableView .setEditing(true, animated: true)]
}
}
你混淆了Swift和Objective-C代码,应该是这样的
@IBAction func edit(sender: UIButton) {
if tableView.isEditing {
tableView.setEditing(false, animated: false)
} else{
tableView.setEditing(true, animated: true)
}
}