質問はかなり広く聞かれるので、その質問に答えるのは簡単ではありませんが、最善を尽くします。
まず、メイン スレッドをブロックしないように高価な処理を行う必要がある場合は、通常、バックグラウンド スレッドをディスパッチします。これはかなり重要です。あなたがしていることに通常の UIImageView を使用していない理由はよくわかりませんが、以下を実装してみてください:
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *CellIdentifier = @"YourCell";
MyCellClass *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
cell = [[MyCellClass alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier];
}
/*
Whatever Code you want
*/
NSArray* params =@[cell.myImageView, @"http://myfancyimages.com/image.png"];
[self performSelectorInBackground:@selector(loadEventImageWithParameters:) withObject:params];
return cell;
}
そして今、関数を追加します:
- (void) loadEventImageWithParameters:(id) parameters {
NSArray* params = [[NSArray alloc] initWithArray:(NSArray*)parameters];
NSURL *url = [NSURL URLWithString:[params objectAtIndex:0]];
UIImage *image = [UIImage imageWithData: [NSData dataWithContentsOfURL:url]];
UIImageView* theImageView = (UIImageView*) [params objectAtIndex:0];
[theImageView setImage:image];
}
ロードする画像がたくさんある場合は、Grand Central Dispatch ですべてのリソースを「盗む」ことがないように、プロセスをキューに入れることをお勧めします。詳細については、この優れた投稿http://www.raywenderlich.com/4295/multithreading-and-grand-central-dispatch-on-ios-for-beginners-tutorialをお読みください。
役に立ったことを願っています