Cell复用问题

来源:互联网 发布:网络教育去哪报名? 编辑:程序博客网 时间:2024/05/17 16:01

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

{

    staticNSString *contactlistcellid =@"InviteJoinListViewCellidentifier";

   InviteJoinListViewCell *cell = [tableViewdequeueReusableCellWithIdentifier:contactlistcellid];

   if (cell ==nil) {

        cell = [[InviteJoinListViewCellalloc]initWithStyle:UITableViewCellStyleDefaultreuseIdentifier:contactlistcellid];

        cell.selectionStyle =UITableViewCellSelectionStyleNone;

        

       UITapGestureRecognizer * tap = [[UITapGestureRecognizeralloc]initWithTarget:selfaction:@selector(cellSelectBtnClicked:)];

        cell.contentView.userInteractionEnabled =YES;

        [cell.contentViewaddGestureRecognizer:tap];

        

    }

   AddressBook *book = [self.localAddressBook[self.allAddressKeys[indexPath.section]]objectAtIndex:indexPath.row];

    cell.portraitImg.image = book.head;

    cell.nameLabel.text = book.name;

    cell.numberLabel.text = book.phones.allValues.firstObject;

    cell.selecImage.tag =indexPath.row+1000;

    

    //判断selectedArray里面有没有当前这个数据

   if ([_selectedArraycontainsObject:book]) {

        cell.selecImage.image = [UIImageimageNamed:@"select_account_list_checked"];

    }

   else{

        cell.selecImage.image = [UIImageimageNamed:@"select_account_list_unchecked"];

    }

   return cell;

}



/** 获取 tableview 的可见的所有 cell但是复用时候会有问题*/

    NSArray * cells = [tableView visibleCells];



0 0