【发布时间】:2015-01-07 16:08:34
【问题描述】:
我有 UITableView,我需要从文档目录中列出我保存的图像,我使用代码 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];
});
}); 将图像异步显示到 UITableView 但 UITableView 在滚动到顶部和底部时滞后。
【问题讨论】:
标签: objective-c uitableview nsdocumentdirectory