Проблема ReusableCellWithIdentifier в cellForRowAtIndexPath
В моем приложении у меня есть один imageView и один UILabel. Для ImageView я назначил ему асинхронное изображение, и оно работает нормально, но метки первой и последней строки перекрываются при прокрутке таблицы.
Вот мой код:
<code>- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { productObject=[appDelegate.productArray objectAtIndex:indexPath.row]; static NSString *CellIdentifier = @"Cell"; UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier]; UILabel *nameLabel; if (cell == nil) { cell = [[[UITableViewCell alloc] initWithFrame:CGRectZero reuseIdentifier:CellIdentifier] autorelease]; cell.selectionStyle = UITableViewCellSelectionStyleBlue; } else { AsyncImageView* oldImage = (AsyncImageView*)[cell.contentView viewWithTag:999]; [oldImage removeFromSuperview]; } CGRect nameLabelRect = CGRectMake(70,80,150,15); nameLabel = [[UILabel alloc] initWithFrame:nameLabelRect]; nameLabel.text = [NSString stringWithFormat:@"%@",productObject.productname]; nameLabel.textAlignment = UITextAlignmentCenter; nameLabel.lineBreakMode = UILineBreakModeCharacterWrap; nameLabel.font = [UIFont boldSystemFontOfSize:15]; nameLabel.backgroundColor = [UIColor clearColor]; [cell.contentView addSubview: nameLabel]; } </code>