I'm finding that if you set a table view into editing mode, upon scrolling the table after deleting a row the cell edit control (the red minus sign on the left) is in a random state (turned vertical or horizontal) on the rest of the cells as you scroll the table. Presumably because I'm reusing cells like this:
cell = [tableView dequeueReusableCellWithIdentifier:cellIdentifier];
How can I force the edit control to be in the correct state for each cell? It should always be in the default horizontal state unless I tap it to delete a cell.
EDIT: Here's the cell code:
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
static NSString *cellIdentifier = @"WhateverIdentifier";
MyCell *cell = nil;
//This IF statement fixes the problem, but then I'm not reusing the cells
if (!tableView.isEditing) {
cell = [tableView dequeueReusableCellWithIdentifier:cellIdentifier];
}
if (!cell) {
cell = [[[NSBundle mainBundle] loadNibNamed:@"MyCell" owner:self options:nil] objectAtIndex:0];
}
//customize cell
return cell;
}
Are you calling [super prepareForReuse]
in the method prepareForReuse
of your custom cell?
That resolved my problem.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With