JSON ファイルからいくつかの画像と文字列を解析しています。解析は正常に機能しますが、画像の読み込みが非常に遅くなります。UITableViewCellを押すと、UITableViewがコンテンツをより速く表示することに気付きました。誰かがその修正を知っていますか?
これが私が使用するコードです。CPU 使用率を低く抑えるために NSOperationQueue を使用します。
NSDictionary *dict;
dict = [application objectAtIndex:indexPath.row];
name = [dict objectForKey:@"name"];
detileName = [dict objectForKey:@"detailName"];
itmsLink = [dict objectForKey:@"itms-serviceLink"];
icon = [dict objectForKey:@"icon"];
developer = [dict objectForKey:@"developer"];
version = [dict objectForKey:@"version"];
category = [dict objectForKey:@"category"];
rating = [dict objectForKey:@"rating"];
ratingNumbers = [dict objectForKey:@"ratingNumber"];
description = [dict objectForKey:@"description"];
developerEmails = [dict objectForKey:@"developerEmail"];
[downloadQueue addOperationWithBlock:^{
cell.AppName.text = name;
cell.category.text = category;
cell.rater.text = [NSString stringWithFormat:@"(%@)", ratingNumbers];
if ([rating intValue] == 1) {
cell.rating.image = [UIImage imageNamed:@"1.png"];
}
if ([rating intValue] == 2) {
cell.rating.image = [UIImage imageNamed:@"2.png"];
}
if ([rating intValue] == 3) {
cell.rating.image = [UIImage imageNamed:@"3.png"];
}
if ([rating intValue] == 4) {
cell.rating.image = [UIImage imageNamed:@"4.png"];
}
cell.itms = itmsLink;
cell.AppIcon.image = [UIImage imageWithData:[NSData dataWithContentsOfURL:[NSURL URLWithString:icon]]];
cell.number.text = [NSString stringWithFormat:@"%li", (long)indexPath.row + 1];
}];