Reloading custom UITableViewCell after reordering cells

后端 未结 6 1421
忘了有多久
忘了有多久 2021-02-15 16:04

I have UITableView which uses custom UITableViewCells. The cells can have one of three types of background images (set in each cell\'s .backgrou

6条回答
  •  借酒劲吻你
    2021-02-15 16:45

    the apis for partially reloading rows in the ios sdk doesn't function well (that's why ppl follow this post here)

    I end up using timer to reload the whole data after reordering animation finishes. It works for me.

    - (void)tableView:(UITableView *)tableView moveRowAtIndexPath:(NSIndexPath *)fromIndexPath toIndexPath:(NSIndexPath *)toIndexPath 
    {
        //things to be done when reordering rows
        ....
    
    
        //issue a timer to reload data
        NSTimer* timer = [NSTimer scheduledTimerWithTimeInterval: 0.1
                                                 target: self
                                               selector:@selector(updateRow)
                                               userInfo: nil repeats:NO];
    
    
    }
    
    
    -(void) updateRow
    {
    
        [self.table reloadData];
    
    }
    

提交回复
热议问题