Reputation: 130
I created a custom class of UITableViewCell with some variables for different state on UIGestureRecognizer.
For exemple :
class CustomClass : UITableViewCell {
var isDisabled : Bool! = false
}
I have a swipe gesture to detect that the user want disabled the cell. So when the user swipe, I set my variable "isDisabled" to true.
Everything works fine until here.
But, if the first row has the variable "isDisabled" to true and I scroll in my tableView, the first row load at the bottom of the page has the variable "isDisabled" to true too, but the user don't say that he want this cell disabled.
So, have you any idea how I can solved my problem ?
Thanks
Upvotes: 0
Views: 53
Reputation: 23451
The issue you explain is regarding the reuse cells bahaviour of the UITableView
. You can solve in different ways, I'll try to explain you one of them:
Array
, or something else) of Bool
for example, with the size of the numbers of cells in your UITableView
and whenever you detect a swipe gesture mark the position in the array for the indexPath.row
to true
or false
depends of it state. This keep the status of the cells for each index.I hope this help you.
Upvotes: 2