My UITableView показывает некоторое ДЕЙСТВИТЕЛЬНО странное поведение.UITableViewCell иногда показывает правильную информацию иногда неправильно?
Вот картина того, что происходит:
Im тестирование заполнения UITableView, добавив некоторую информацию. И каждый раз для каждой ячейки я обновил событие до Цель и имя игрока tet. Да, каждый раз даже для последних 3 ячеек, которые вы можете видеть, появляется какое-то странное поведение.
после оценки «10-0» я решил, что другая команда забивает одноименным названием tet. Первый раз он показывает изображение с обеих сторон И имя не отображается. Второй раз он показывает правильно и в третий раз, как вы можете видеть, что он снова показывает ошибку.
BUT Если я перехожу к другому виду, а затем вернусь, все будет выглядеть так, как должно.
Вот еще один пример:
В этом примере я решил, чтобы каждая сторона счет каждый второй раз с именем «twfr». Как видите, в ячейке счёта 5-2 идет ошибка.
У меня нет идеи, что может быть причиной этого. Я попытался с помощью этого кода
[self.tableView reloadRowsAtIndexPaths:[NSArray arrayWithObjects:indexPath, nil] withRowAnimation:UITableViewRowAnimationNone];
В - (UITableViewCell *) Tableview: (UITableView *) Tableview cellForRowAtIndexPath: (NSIndexPath *) indexPath
он сделал работу, но вы могли ясно видеть, когда он идет не так но он быстро меняет это и показывает неправильное ТАКЖЕ, он сильно затягивается при прокрутке. Так, пожалуйста, ребята, что может вызвать эту проблему?
EDIT2 Проводка больше кода
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
if (indexPath.section == 0) {
static NSString *identifier = @"MainCell";
GamesInfoTableViewCell *cell = (GamesInfoTableViewCell *)[tableView dequeueReusableCellWithIdentifier:identifier];
cell.userInteractionEnabled = NO;
//cell.backgroundColor = detailCol;
[cell.homeTeamLabel setFont:[UIFont boldSystemFontOfSize:16]];
[cell.awayTeamLabel setFont:[UIFont boldSystemFontOfSize:16]];
cell.gameTimeLabel.textColor = TEXT;
cell.sectionName.textColor = TEXT;
cell.liveButton.image = [UIImage imageNamed:@"LiveButton.png"];
if ([_GameInfoDictionary[@"time"] isEqualToString:@"FT"])
cell.liveButton.hidden = TRUE;
cell.sectionName.text = self.selectedSection;
cell.homeTeamLabel.text = [self.GameInfoDictionary objectForKey:@"homeTeam"];
cell.awayTeamLabel.text = _GameInfoDictionary[@"awayTeam"];
cell.gameTimeLabel.text = _GameInfoDictionary[@"time"];
cell.homeTeamScoreLabel.text = _GameInfoDictionary[@"homeScore"];
cell.awayTeamScoreLabel.text = _GameInfoDictionary[@"awayScore"];
return cell;
}
// If its the other section
static NSString *otherSection = @"events";
GamesInfoTableViewCell *cell1 = (GamesInfoTableViewCell *)[tableView dequeueReusableCellWithIdentifier:otherSection];
cell1.backgroundColor = TABLECOLOR;
// Configure the cell...
cell1.gameTimeLabel.textColor = TEXT;
cell1.homeNameLabel.textColor = TEXT;
cell1.awayNameLabel.textColor = TEXT;
// Select the event object for the specefik row
NSMutableDictionary *gameInfoObject =[_events objectAtIndex:indexPath.row];
// Seperate event and name
NSArray * array = [gameInfoObject[@"eventType"] componentsSeparatedByString:@"-"];
NSString * typeEvent = [array objectAtIndex:0];
NSString * nameOfPlayer = [array objectAtIndex:1];
UIImage *imageType;
//Change the typeofevent name here to goal so it matches with the image name,
// Set the name of the event same as the picture to load correct image
NSMutableString *eventNameToImage = [NSMutableString string];
[eventNameToImage appendString:typeEvent];
[eventNameToImage appendString:@".png"];
imageType = [UIImage imageNamed:eventNameToImage];
if ([typeEvent isEqualToString:goal] || [typeEvent isEqualToString:penaltyGoal] || [typeEvent isEqualToString:owngoal])
cell1.bothScoreLabel.text = gameInfoObject[@"eventScore"];
else
cell1.bothScoreLabel.hidden = YES;
cell1.gameTimeLabel.text = gameInfoObject[@"eventTime"];
if ([gameInfoObject[@"selectedTeam"] isEqualToString:@"homeTeam"])
{
cell1.homeNameLabel.text = nameOfPlayer;
cell1.awayNameLabel.hidden = YES;
cell1.homeTeamImage.image = imageType;
if([typeEvent isEqualToString:owngoal]){
[cell1.homeOwnGoalLabel setFont:[UIFont boldSystemFontOfSize:7]];
cell1.homeOwnGoalLabel.hidden = NO;
}
else if([typeEvent isEqualToString:penaltyGoal] || [typeEvent isEqualToString:penaltyMiss])
cell1.homeNameLabel.text = [cell1.homeNameLabel.text stringByAppendingString:@" (str.)"];
}
else
{
cell1.awayNameLabel.text = nameOfPlayer;
cell1.homeNameLabel.hidden = YES;
cell1.awayTeamImage.image = imageType;
if([typeEvent isEqualToString:owngoal]){
[cell1.awayOwnGoalLabel setFont:[UIFont boldSystemFontOfSize:7]];
cell1.awayOwnGoalLabel.hidden = NO;
}
else if([typeEvent isEqualToString:penaltyGoal] || [typeEvent isEqualToString:penaltyMiss])
cell1.awayNameLabel.text = [cell1.awayNameLabel.text stringByAppendingString:@" (str.)"];
}
//[self.tableView reloadRowsAtIndexPaths:[NSArray arrayWithObjects:indexPath, nil] withRowAnimation:UITableViewRowAnimationNone];
return cell1;
}
Не перезагружайте строки внутри 'cellForRowAtIndexPath:'! –
Можете ли вы разместить свой код 'cellForRowAtIndexPath:'? –
@AaronBrager только что добавил.Его alot: P –