【发布时间】:2019-04-08 08:23:32
【问题描述】:
使用UITableView 编辑方法可以正常工作,但使用UIButton 则无法正常工作。
func tableView(_ tableView: UITableView, editActionsForRowAt indexPath: IndexPath) -> [UITableViewRowAction]? {
let deleteAction = UITableViewRowAction(style: .normal, title: "Delete") { (deleteAction, indexPath) in
deleteApm(Id: myString)
self.AArrayList.remove(at: indexPath.row)
tableView.deleteRows(at: [indexPath], with: .fade)
}
return [deleteAction]
}
func deleteApm(Id:String)
{
//...................................
}
@IBAction func myButt(_ sender: UIButton) {
let cancelBtn = sender.tag
}
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell
{
let cell = tableView.dequeueReusableCell(withIdentifier: "ACell", for: indexPath) as! ATableViewCell
cell.cancelBtn.addTarget(self, action: #selector(self.myButt(_:)), for: .touchUpInside)
return cell
}
使用这个我在按钮中调用了相同的删除方法,但使用UIButton 删除不起作用。
使用UITableView 工作正常...
【问题讨论】:
标签: ios swift uitableview button