【问题标题】:Programmatically swipe UITableViewCell?以编程方式滑动 UITableViewCell?
【发布时间】:2016-07-06 07:28:21
【问题描述】:
有没有办法以编程方式触发在具有编辑操作的 UITableViewCell 上向左滑动的等价物?这与简单的 [tableView setEditing:YES animated:YES] 不同,因为该方法将整个表格设置为编辑模式,并显示插入/删除左侧附件视图和/或重新排序控件,而不是单行的编辑操作。
【问题讨论】:
标签:
ios
uitableview
uitableviewrowaction
【解决方案1】:
您可以从UITableViewDelegate 使用optional func tableView(_ tableView: UITableView, editingStyleForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCellEditingStyle。并为您要滑动的单元格返回UITableViewCellEditingStyleDelete。当您想触发滑动时,使用func reloadRowsAtIndexPaths(_ indexPaths: [NSIndexPath], withRowAnimation animation: UITableViewRowAnimation) 重新加载该单元格。