Обычно мы настраиваем Cell вне состояния Cell nil. В моем случае я делаю то же самое, что конвертирует NSData в изображение вне Cell nil. Таким образом, каждый раз, когда я запускаю таблицу запроса и перезагрузки, она идеально преобразует данные в изображение для конкретной ячейки. Но после перезагрузки таблицы моя проблема в том, что когда я просматриваю таблицу, каждый раз, когда она преобразует NSData в изображение, что очевидно. Мне нужно избегать этого преобразования при прокрутке после перезагрузки таблицы.Состояние UITableViewCell nil
static NSString *CellIdentifierImage = @"CellIdentifierImage";
if(indexPath.section == 0)
{
NewsImageCell *newsImageCell = [tableView dequeueReusableCellWithIdentifier:CellIdentifierImage];
if (newsImageCell == nil)
{
NSLog(@"CellNil");
newsImageCell = [[NewsImageCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifierImage];
newsImageCell.selectionStyle = UITableViewCellSelectionStyleNone;
}
if([[ApplicationData sharedInstance].arrTop10NewsHome count]>0)
{
NSMutableDictionary *dicSource = [arrSource objectAtIndex:indexPath.row];
NSURL *urlImage = [NSURL URLWithString:[dicSource retrieveForPath:@"ItemImage"]];
newsImageCell.lblNewsHeading.text = [dicSource objectForKey:@"Title"];
[newsImageCell.loadingIndicator startAnimating];
dispatch_queue_t queue = dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_HIGH, 0ul);
dispatch_async(queue, ^{
UIImage *image = [UIImage imageWithData:[NSData dataWithContentsOfURL:urlImage]];
dispatch_sync(dispatch_get_main_queue(), ^{
newsImageCell.imgVwNews.image = image;
[newsImageCell.loadingIndicator stopAnimating];
});
});
}
return newsImageCell;
}
Цените ваши идеи Заранее спасибо !!!