模拟UITableViewCell的左拖动

时间:2017-08-02 19:59:30

标签: ios uitableview uitableviewrowaction

我的目标是向初次向用户表明我的tableview上的单元格是可编辑的。为了表明这一点,我的目标是设置一个轻微的左拖动动画。

在以编程方式生成触摸事件之外,我不确定是否可以使用UITableViewRowAction

来实现这样的目标

例如,以下是完整拖动事件的以下实现:

func tableView(_ tableView: UITableView, editActionsForRowAt indexPath: IndexPath) -> [UITableViewRowAction]? {

        if indexPath.section == 1 {
            let editAction = UITableViewRowAction(style: .normal, title: "Allow") { (rowAction, indexPath) in

                tableView.beginUpdates()
                //...implementation methods not included for brevity 
                tableView.endUpdates() 
            }
            editAction.backgroundColor = DisplayColors.AllViews.WarnColor
            return [editAction]
        } 
}

但是,以上仅适用于用户物理拖动单元格的情况。我不知道是否有办法以编程方式调用此方法只是为了证明该单元格具有此功能。

0 个答案:

没有答案