IPhone UITableView missing disclosure-button after clicking delete button when reusing UITableViewCell

I have a UITableViewcustom iPhone that displays the UITableViewCelldisclosure button icon on the right.
When I scroll the cell, the disclosure button is automatically replaced by the red “Delete” button. If I click the Delete button, the row will be deleted from the table, but then something strange will happen.
When I look at the table and the deleted cell is reused , the data loads correctly, but the expand button is missing .

I tried resetting a button in a method prepareForReuse, but without success.

I don’t understand what I’m missing, because the behavior is similar to the Mail application, therefore it should be supported by iPhone OS.

BTW: UITableViewCellbooting from NIB.

+3
source share
1 answer

it seems that I solved the problem by adding in

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath 

this line of code:

[cell setAccessoryType:UITableViewCellAccessoryDetailDisclosureButton];

I think this line is useless for normal cells, but restores the correct behavior of a cell with reusable cells after deletion ...

Anyway, to remove the line I used in

- (void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath 

this (I think) standard line:

 [tableView deleteRowsAtIndexPaths:[NSArray arrayWithObject:indexPath] withRowAnimation:YES];

Thanks Stefano

+5
source

Source: https://habr.com/ru/post/1706711/


All Articles