ios - 以编程方式滑动 UITableViewCell?

标签 ios uitableview uitableviewrowaction

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

最佳答案

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

关于ios - 以编程方式滑动 UITableViewCell?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36103077/

相关文章:

iphone - 3.5 屏幕上的 View 大小错误

ios - 尝试通过 Swift 使用亚马逊广告时出现 "Failed to import bridging header"错误

ios - Swift 3 自己的 UITableViewCellActionButton 字体

ios - 我想通过 UITableViewRowButtonAction 打开一个新的 ViewController

objective-c - 如何创建可重用的 iOS 控件?

iOS UICollectionView 在垂直 UICollectionView 单元格内水平滚动,重用

ios - SDWebImage - UITableView 中的内存泄漏?

ios - 在 Bubble Tableview cell tap 上读取 NSBubbledata

ios - UIToolbar 在带有 UIPickerView 的自定义 UITableViewCell 中没有响应

ios - 自动滚动到 Swift 中 PFQueryTableViewController 中的下一个单元格