के साथ UITableViewCell का पुन: उपयोग करना मैं का उपयोग UITableViewCell
की छवियों को असीमित रूप से लोड करने के लिए कर रहा हूं। यह कुछ सीमावर्ती मामलों को छोड़कर अच्छी तरह से काम करता है जिसमें सेल का पुन: उपयोग किया जाता है, और पिछला ब्लॉक गलत छवि लोड करता है।जीसीडी
मेरे वर्तमान कोड इस तरह दिखता है:
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
static NSString *CellIdentifier = @"Cell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (!cell) {
cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier] autorelease];
}
NSString *imagePath = [self imagePathForIndexPath:indexPath];
dispatch_queue_t queue = dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_HIGH, 0ul);
dispatch_async(queue, ^{
UIImage *image = [UIImage imageWithContentsOfFile:imagePath];
dispatch_sync(dispatch_get_main_queue(), ^{
cell.imageView.image = image;
[cell setNeedsLayout];
});
});
return cell;
}
जहाँ तक मुझे पता के रूप में GCD कतारों रोका नहीं जा सकता। तब इस सीमा के मामले को कैसे रोका जा सकता है? या मुझे इस समस्या को हल करने के लिए जीसीडी के बजाय कुछ और इस्तेमाल करना चाहिए?
मैं GMGridView उपयोग कर रहा हूँ छवि थंबनेल की बहुत बड़ी राशि को दिखाने के लिए और इसके साथ ठीक उसी समस्या आ। मैं फ्लाई पर अपने वेबसर्वर से थंबनेल लोड करने के लिए जीसीडी का भी उपयोग कर रहा हूं। – Humayun