以编程方式刷UITableViewCell?

时间:2016-03-19 14:42:51

标签: ios uitableview uitableviewrowaction

有没有办法以编程方式触发相当于在具有编辑操作的UITableViewCell上向左滑动?这与简单[tableView setEditing:YES animated:YES]不同,因为该方法将整个表设置为编辑模式,并显示插入/删除左侧附件视图和/或重新排序控件,而不是单行的编辑操作。

1 个答案:

答案 0 :(得分:-1)

您可以使用UITableViewDelegate中的optional func tableView(_ tableView: UITableView, editingStyleForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCellEditingStyle。并为要滑动的单元格返回UITableViewCellEditingStyleDelete。如果要触发滑动,请使用func reloadRowsAtIndexPaths(_ indexPaths: [NSIndexPath], withRowAnimation animation: UITableViewRowAnimation)重新加载该单元格。