Привет, я использую GCD для загрузки изображения в uitableview. Теперь проблема заключается в анимации изображения. Я назвал три изображения с сервера он загружает в клетку, но я получил 3 проблемыЗагрузка изображения Анимация с использованием GCD
1) Одиночное изображение повторяется во всех трех клетках
2) первые и последние изображения клеток мигания и изменения
3) когда изображение изменилось, оно повторяется во всех ячейках.
Даже если я не давал анимации ни еще одушевляет т.е. Мигание
Код:
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier] autorelease];
}
// Configure the cell...
[imageArray retain];
//get a dispatch queue
dispatch_queue_t concurrentQueue = dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0);
//this will start the image loading in bg
dispatch_async(concurrentQueue, ^{
NSData *image = [[NSData alloc] initWithContentsOfURL:[NSURL URLWithString:[imageArray objectAtIndex:indexPath.row]]];
//this will set the image when loading is finished
dispatch_async(dispatch_get_main_queue(), ^{
cell.imageView.image = [UIImage imageWithData:image];
[tableView reloadRowsAtIndexPaths:[NSArray arrayWithObject:indexPath] withRowAnimation:UITableViewRowAnimationNone];
});
});
return cell;
}
Благодаря человеку. Правильно работает –
Это был мой старый код. Я только что исправил это. – Tobol