如何在iOS的当前单元格之外获得触摸?(Swift) [英] How to get touch outside current cell in iOS ?(swift)

查看:105
本文介绍了如何在iOS的当前单元格之外获得触摸?(Swift)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在向左/右创建自定义SwipeableCell。我想检测当前单元格外部的触摸以使其恢复默认状态。我怎样才能做到这一点?

I am creating a custom SwipeableCell to left/right. I want to detect touch outside of current cell to return it to default state. How can I do that?

我的程序图片

我知道如何将单元格恢复为默认状态,但是我不知道如何检测触摸。

I know how to return cell to default state, but I don't know how to detect touch.

推荐答案

在将当前NSIndexPath滑动到某个变量时,将其保存在viewController上。

Lets save the current NSIndexPath on the viewController, when you swipe on it to some variable.

在didSelectCellForRow中,如果已保存indexPath与传入的indexPath不相等,因此可以在保存的indexPath处恢复单元格的状态。

In didSelectCellForRow, if the saved indexPath is not equal with the indexPath coming in, than lets restore the state of cell at the saved indexPath.

这篇关于如何在iOS的当前单元格之外获得触摸?(Swift)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆