i have custom cell with 2 buttons(the function of these buttons is just to disable the button that was pressed).
When i use dequeueReusableCellWithIdentifier in this classic way:
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
static NSString *CellIdentifier = @"Cell";
cell = ((MainCell*)[tableView dequeueReusableCellWithIdentifier:CellIdentifier]);
if (cell == nil) {
[[NSBundle mainBundle] loadNibNamed:@"MainCell" owner:self options:nil];
}
return cell;
}
the UITableView has 1 section, the problem is: on the first cell when i pressed the button to disabled it and than scroll down to show other cells, when i scroll up again the first cell is a new cell and the button is enabled.
I know that reuseIdentifier is used to no recreated a cell if was already created, but in this way i lost all info of the cells that are not more visible.
Any idea?
Thanks in advance
I’m having similar issues–I think the problem is that only the visible cells are actually in memory at any given time, and when it redisplays an old cell it actually just dequeues a new one. I think the solution is to use the
- (void)tableView:(UITableView *)tableView willDisplayCell:(UITableViewCell *)cell forRowAtIndexPath:(NSIndexPath *)indexPathdelegate method:If anyone has a better solution, I’d be really happy to hear it.