在我的 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/