Temporarily disable UITableViewCell recycling

My UITableViewCells can accept data entry. When working in one cell, it would be completely natural if the user wants to scroll up, check something in another cell, and then return to the first cell and continue recording data.

The problem is that this often causes the UITableView to recycle the cell, which can lead to chaos in my program.

Is there a way to temporarily tell iOS not to recycle the cell?

As soon as the data recording is completed, I am fine if it is reworked.

I must add that data recording uses a custom keyboard. Thus, the status of the first responder is not a problem.

+3
source share
4 answers

As Izzy said, this is not an ordinary way of working. And going against the way lists work can cause problems. If you want to reduce your problem, save the contents of your cell in memory and use this saved content to replenish the cell when CallDisplayCell is called, and not to restore it all from the very beginning every time.

+2
source

Give another CellIdentifier cells that are significantly different. If the cell at the bottom has its own identifier, then when the user scrolls to the bottom, he will not process your cell at the top. However, this still saves your cell at the top of the reuse queue, so when you go back to the top, you won’t need to recreate it.

+4

, dequeueReusableCellWithIdentifier: UITableView.

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

+3

Gendolkari dequeue. , , KVC, .

, . , , , . [NSIndexPath description] . reuseIdentifier - , Objective-C, KVC:

[cell setValue:[[self.tableView indexPathForCell:cell] description] forKey:@"reuseIdentifier"];

, cellForRowAtIndexPath:

UITableViewCell *cell = [self.tableView dequeueReusableCellWithIdentifier:@"cellIdentifier"];

, reuseIdentifier.

However, if we scroll down and then scroll back, we probably want to display the original cell that we removed from the dequeue loop. To do this, when we reuse the cell, we first try to delete the cell based on indexPath, and if we cannot find this attempt to deactivate the cell simply based on the base line of the cell identifier:

UITableViewCell *cell;
cell = [self.tableView dequeueReusableCellWithIdentifier:[indexPath description]];
if (!cell) cell = [self.tableView dequeueReusableCellWithIdentifier:@"cellIdentifier"];

If you want to return this cell to the dequeue loop, just change the reuseIdentifier to its original value:

[cell setValue:@"cellIdentifier" forKey:@"reuseIdentifier"];
0
source

All Articles