[英]How I can reload tableview data after the animation of fade swipeAction completed
我使用SwipeCellKit為我的tableview做滑動動作。 我嘗試對單元格的annexType進行向左滑動檢查或松開,並且一切正常,但是在我按下檢查后,tableview立即重新加載了數據,並且我看不到roollback動畫檢查按鈕。 所以我想問一問動畫結束后如何調用重載數據。
我有這樣的事情:
但是我想要這樣的淡入淡出動畫
我的代碼:
override func tableView(_ tableView: UITableView, editActionsForRowAt indexPath: IndexPath, for orientation: SwipeActionsOrientation) -> [SwipeAction]? {
var action = super.tableView(tableView, editActionsForRowAt: indexPath, for: orientation) ?? []
guard orientation == .left else { return action }
let checkAction = SwipeAction(style: .destructive, title: nil) { action, indexPath in
self.completeItem(at: indexPath)
}
action.append(checkAction)
return action
}
private func completeItem(at indexPath: IndexPath){
if let item = itemArray?[indexPath.row]{
do{
try realm.write {
item.done = !item.done
}
}
catch{
print( error.localizedDescription)
}
}
tableView.reloadData()
}
為了在選擇時隱藏動作,您需要為動作設置hidesWhenSelected屬性。
checkAction.hidesWhenSelected = true
另外,該示例不會重新加載tableView。 而是使用動畫刪除點。 您將需要手動延遲重新加載,直到隱藏動畫完成。
有關屬性,請參見第156行
動畫請參見第256-273行https://github.com/SwipeCellKit/SwipeCellKit/blob/develop/Example/MailExample/MailTableViewController.swift
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.