Smooth reload of uitableview data when rows are deleted

后端 未结 1 1605
情深已故
情深已故 2021-01-29 01:31

I am trying to reload a uitableview when it scrolls to the bottom of the screen. I delete the first few rows and add more rows to the bottom. Before the news ro

相关标签:
1条回答
  • 2021-01-29 01:39

    delete the data from the data source in tableView delegate.

     -(void) tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath
        {
    
    
                NSString *key = [keys objectAtIndex:indexPath.section];
                NSMutableArray *nameSection =[names objectForKey:key];
    
                int itemID=item.ID;
                if ([nameSection count]==1) {
                    [self.keys removeObjectsInArray:[NSArray arrayWithObject:key]];
    
                    [tableView deleteSections:[NSIndexSet indexSetWithIndex:indexPath.section] withRowAnimation:UITableViewRowAnimationFade];
                }
                else {
                    [nameSection removeObjectAtIndex:indexPath.row];
                    [self.names setValue:nameSection forKey:key];
    
                    [tableView deleteRowsAtIndexPaths:[NSArray arrayWithObject:indexPath] 
                                     withRowAnimation:UITableViewRowAnimationFade];
                }
            }
    

    check this too

    0 讨论(0)
提交回复
热议问题