ios - 在编辑表格 View 单元格时获取滑动事件

标签 ios uitableview swift

在我的 UITableview 中,我所有的单元格都是可编辑的,.Delete 是它们的编辑风格。对于我的逻辑——其解释与本次讨论的范围无关——要起作用,我必须在用户向左滑动时或者用户决定根本不删除单元格并向右滑动时获取事件。 (如果我在用户开始滑动时收到事件就足够了。我不需要连续的滑动事件。)这可能吗?我可以使用任何委托(delegate)方法来提供此类信息吗?

最佳答案

我想引用 Apple Documentation

您可以使用委托(delegate)方法:

optional func tableView(_ tableView: UITableView, willBeginEditingRowAtIndexPath indexPath: NSIndexPath)

当用户在单元格中水平滑动或苹果希望这样声明时,将调用此方法:

This method is called when the user swipes horizontally across a row; as a consequence, the table view sets its editing property to true (thereby entering editing mode) and displays a Delete button in the row identified by indexPath. In this "swipe to delete" mode the table view does not display any insertion, deletion, and reordering controls. This method gives the delegate an opportunity to adjust the application's user interface to editing mode. When the table exits editing mode (for example, the user taps the Delete button), the table view calls tableView:didEndEditingRowAtIndexPath:.

关于ios - 在编辑表格 View 单元格时获取滑动事件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29781269/

相关文章:

ios - Swift:字符串的区别?与作为?字符串

ios - Fabric + Appsee 与 Ad Hoc/Release API key

iphone - 如何了解ios sdk中的网络详细信息和使用

iOS:使表格 View 单元格(或 TextView ?)根据需要增大或缩小

swift - 在 Swift 中使用 UserDefaults 保存 SCNVector3 的值

ios - 在 NSUserDefaults 中存储类并在下一个 View 中访问

iphone - FBSession 的 Facebook SDK 3.0 权限数组持有错误的权限

swift - UITableView 显示不正确

ios - 尝试以编程方式添加 UITableView() 时未在 UIViewController 中显示

swift - 在 SKScene 中调用 UIActivity ViewController