UITableViewCell reutilizar buenas prácticas
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
static NSString *CellIdentifier = @"NotificationViewCell";
CardViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if(cell==nil){
NSArray *nib = [[NSBundle mainBundle] loadNibNamed:@"CardViewCell" owner:self options:nil];
cell = [nib objectAtIndex:0];
cell.contentView.backgroundColor=[UIColor clearColor];
[ModelClass addSublayer:cell.contentView];
cell.cellbg.layer.cornerRadius = 8;
cell.cellbg.layer.masksToBounds = YES;
cell.cellbg.layer.borderWidth = 1;
cell.cellbg.layer.borderColor = [[UIColor grayColor] CGColor];
cell.logoImage.layer.cornerRadius = 8;
cell.logoImage.layer.masksToBounds = YES;
cell.logoImage.layer.borderWidth = 1;
cell.logoImage.layer.borderColor = [[UIColor grayColor] CGColor];
Merchant *merchantList= [self.cardListArr objectAtIndex:indexPath.row];
cell.nameLab.text=merchantList.name;
NSLog(@"merchantList.myloyalty.points=%@",merchantList.myloyalty.points);
// NSLog(@"memberNO=%@",merchantList.myloyalty.memberNO);
cell.integralLab.text=[NSString stringWithFormat:NSLocalizedString(@"points_dot", @"") ,[merchantList.myloyalty.points intValue]];
cell.cardNumberLab.text=[NSString stringWithFormat:@"%@%@",NSLocalizedString(@"ID", nil), merchantList.myloyalty.memberNO];
if(![ModelClass isBlankString:merchantList.introPic])
{
NSLog(@"merchantList.introPic=%@",merchantList.introPic);
[cell.logoImage setImageUrl:merchantList.introPic];
}
}
return cell;
}
Quiero usar el código anterior para reutilizar UITableViewCell, no sé si es correcto, quiero obtener un consejo.puede ver mi código que uso si (celda == nula), quiero saber que debo escribir qué código si (celda! = nula) (si (celda == nula) más {debo hacer lo que pueda mejorar la reutilización de la celda })
Si todas las celdas tienen las mismas vistas, pero tienen diferentes alturas, por ejemplo, la vista de imagen a veces es 20 o es 40 y así sucesivamente, cómo lidiar con la situación.