Am having UITableView and i need to list my saved images from document directory am using the code NSArray *sysPaths = NSSearchPathForDirectoriesInDomains( NSDocumentDirectory, NSUserDomainMask, YES );
NSString *docDirectory = [sysPaths objectAtIndex:0];
dispatch_queue_t queue_=dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0);
dispatch_async(queue_, ^{
NSString *filePath=[docDirectory stringByAppendingPathComponent:[NSString stringWithFormat:@"MyFolder_New/%@",[[[tableArray objectAtIndex:indexPath.row] componentsSeparatedByString:@"/"] lastObject]]];
dispatch_async(dispatch_get_main_queue(), ^{
[img setImage:[UIImage imageWithData:[NSData dataWithContentsOfFile:filePath]]];
[indicator stopAnimating];
});
});
for displaying images Asynchronously into UITableView but the UITableView is lagging while scrolling to top and bottom.
Asynchronously load images from document directory into UITableView
164 views Asked by Apple At
1
You need use dispatch_asynch in method tableView:cellForRowAtIndexPath: when you customize cell before return. Steps: 1. get cell from pool. 2. customise it. 3. start dispatch_asynch, what will set correct image (this need check if cell is still same) to cell.
We do it all time and we never have lags. But images appear in cells with delay (it is correct). Try it.