У меня есть прокручиваемый стол. В каждой ячейке я рисую 3 UILabels. Первые несколько клеток выглядят нормально. Но когда я просматриваю таблицу, UILabels, похоже, рисует предыдущие UILabels. На нем, как на ярлыках в ячейке, уже есть старый ярлык, который был очищен. Возможно, я мог бы исправить это, нарисуя фоновый цвет по всей ячейке, каждый раз перерисовывая, но это все еще не объясняет эту странную проблему и почему ее происходит.Прокручиваемый стол с проблемой перерисовывания. Кажется, что очистка
Кто-нибудь знает, почему это происходит и какое решение может быть?
- (UITableViewCell *)tableView:(UITableView *)tableView
cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *CellIdentifier = @"Cell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil)
{
cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault
reuseIdentifier:CellIdentifier] autorelease];
}
Match *aMatch = [appDelegate.matchScoresArray objectAtIndex:indexPath.row];
UILabel * teamName1Label = [[UILabel alloc]initWithFrame:CGRectMake(5,5, 100, 20)];
teamName1Label.textAlignment = UITextAlignmentCenter;
teamName1Label.textColor = [UIColor redColor];
teamName1Label.backgroundColor = [UIColor clearColor];
teamName1Label.text = aMatch.teamName1;
[cell addSubview:teamName1Label];
UILabel *teamVersusLabel = [[UILabel alloc]initWithFrame:CGRectMake(115,5, 40, 20)];
teamVersusLabel.textAlignment = UITextAlignmentCenter;
teamVersusLabel.textColor = [UIColor redColor];
teamVersusLabel.backgroundColor = [UIColor clearColor];
teamVersusLabel.text = @"V";
[cell addSubview:teamVersusLabel];
UILabel *teamName2Label = [[UILabel alloc]initWithFrame:CGRectMake(155,5, 100, 20)];
teamName2Label.textAlignment = UITextAlignmentCenter;
teamName2Label.textColor = [UIColor redColor];
teamName2Label.backgroundColor = [UIColor clearColor];
teamName2Label.text = aMatch.teamName2;
[cell addSubview:teamName2Label];
return cell;
}
Большое спасибо -кода