Are UITableView reloading issues important?

I am trying to understand why it seems that in what order I am loading sections of my UITableView

If I rebooted as follows:

 // Reload section 1 [self.groupDetailsTableView reloadSections:[NSIndexSet indexSetWithIndex:1] withRowAnimation:UITableViewRowAnimationFade]; // Reload section 0 [self.groupDetailsTableView reloadSections:[NSIndexSet indexSetWithIndex:0] withRowAnimation:UITableViewRowAnimationFade]; 

No problem, but if I restart in the opposite order (section 0 first and then section 1), I get an error message:

* Application termination due to the uncaught exception "NSInternalInconsistencyException", reason: "Incorrect update: invalid number of lines in section 1. The number of lines contained in an existing section after updating (2) must be equal to the number of lines contained in this section before updating (1) plus or minus the number of rows inserted or deleted from this section (0 inserted, 0 deleted) and plus or minus the number of lines moved to or from this section (0 moved in, 0 displayed).

However, if I do it like this, there is no error:

 [self.groupDetailsTableView reloadSections:[NSIndexSet indexSetWithIndexesInRange:NSMakeRange(0, 2)] withRowAnimation:UITableViewRowAnimationFade]; 
+4
source share
2 answers

I think there is a problem in updating the UITableview ; you load the table section 1 , and section 0 reloaded. I suggest you use the [tableview beginUpdates] and [tableview endUpdates] right before and right after the reboot, and the problem should go away.

If not, then tell me. Hope this helps.

+9
source

try it

 [self.tableView reloadSections:[NSIndexSet indexSetWithIndex:indexPath.section] withRowAnimation:NO]; 
+1
source

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


All Articles