我编写了以下代码。我试图使它的功能像UIBarButtonItem
编辑项目功能一样,但使用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)
}
}