iOS 避免cel重用机制

来源:互联网 发布:redis 获取当前数据库 编辑:程序博客网 时间:2024/04/27 15:36

   今天在做项目的过程中,遇到了cell重用,经过查找资料和自己的总结,总结出一条简单实用的:

   

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


//    static NSString *CellIdentifier = @"Cell";

    NSString *CellIdentifier = [NSStringstringWithFormat:@"Cell%ld%ld", [indexPathsection],[indexPath row]];////以indexPath来唯一确定cell 

    RegisteredTableViewCell *cell=[tableViewdequeueReusableCellWithIdentifier:CellIdentifier];

    if (!cell) {

        cell=[[RegisteredTableViewCellalloc]initWithReuseIdentifier:CellIdentifier];

       

    

    }

0 0
原创粉丝点击