对于 iOS11,我无法通过trailingSwipeActionsConfigurationForRowAt
委托方法在表格行中使用自定义删除按钮。我认为遗漏了一些东西,但我不知道它是什么。在滑动行时未调用以下方法。任何帮助将不胜感激。
@available(iOS 11.0, *)
func tableView(_ tableView: UITableView, trailingSwipeActionsConfigurationForRowAt indexPath: IndexPath) -> UISwipeActionsConfiguration? {
let deleteAction = UIContextualAction.init(style: UIContextualAction.Style.destructive, title: nil, handler: { (action, view, completion) in
//TODO: Delete
completion(true)
})
deleteAction.backgroundColor = .blue//UIColor(red: 252/255, green: 56/255, blue: 88/255, alpha: 1.0)
deleteAction.image = UIGraphicsImageRenderer(size:CGSize(width:30,height:30)).image { _ in
UIImage(named: "Icon-Trash")!.draw(in : CGRect(x:0,y:0,width:30,height:30))
}
let config = UISwipeActionsConfiguration(actions: [deleteAction])
config.performsFirstActionWithFullSwipe = false
return config
}
任何人都可以发布 iOS11 的工作代码,因为我已经尝试过了。