繁体   English   中英

淡入淡出的swipeAction动画完成后如何重新加载tableview数据

[英]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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM