In UITableViewController, the UI freezes when this method is called:
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
where an image is being loaded into the UITableViewCell.
cell.imageView.image = [UIImage imageWithContentsOfFile:@"filePath"];
The files are locally stored in the documents folder - this is not a remote call. I understand that image-loading while the cell is created cusses the main开发者_运维知识库 thread to freeze, if this was a remote call i would have uses a-synchronic loading but how would you do it for local files?
*images are around 500k.
Need help. Thanks.
For example, make separate thread where you will load images and save reference to them in some array
. When all images will be prepared (or some part of them), you can reload
cell
s that should contains that messages.
In table view controller
you should check if image
is already loaded for that cell
and if it is just take reference and set cell.imageView.image
with it.
精彩评论