在滑动(EG 左)时,我在行文本上划线时遇到问题。
我正在使用 tableview 方法leadingSwipeActionsConfigurationForRowAt
,但在滑动时找不到删除线文本的解决方案。
截至目前,“刷卡”行实际上已被删除。
我想要做什么:
代码:
override func tableView(_ tableView: UITableView, leadingSwipeActionsConfigurationForRowAt indexPath: IndexPath) -> UISwipeActionsConfiguration? {
let complete = completeAction(at: indexPath)
return UISwipeActionsConfiguration(actions: [complete])
}
func completeAction(at indexPath: IndexPath) -> UIContextualAction {
let action = UIContextualAction(style: .destructive, title: "Complete") { (action, view, completion) in
self.kind.remove(at: indexPath.row)
self.tableView.deleteRows(at: [indexPath], with: .fade)
completion(true)
if let context = (UIApplication.shared.delegate as? AppDelegate)?.coreDataStack.persistentContainer.viewContext {
let objectToDelete = self.fetchResultsController.object(at: indexPath)
context.delete(objectToDelete)
do {
try context.save()
} catch {
print(error.localizedDescription)
}
}
}
return action
}