UITableView/UICollectionView 使用dragInteractionEnabled踩坑之滑动速度过快的问题

236 阅读1分钟

UITableView/UICollectionView 使用dragInteractionEnabled踩坑之滑动速度过快的问题

原因是contentinset会影响拖拽时触发列表滚动的区域,且contentiset的bottom设置的越大列表滑动就越快。但是当前状况是必须设置contentinset,可以在 func tableView(_ tableView: UITableView, dragSessionWillBegin session: UIDragSession) 和这个方法 func scrollViewDidScroll(_ scrollView: UIScrollView) 根据需求更改contentiset的bottom为拖拽时的值,在拖拽结束的回调中恢复为正常的值。