画像を含むエントリで TableView を表示するアプリを書いています。cellForRowAtIndexPath
メソッド内で次のコード行を実行して、画像を取得しようとしています。
cell.detailTextLabel.text = [artistData objectForKey:generesKey];
dispatch_async(backgroundQueue, ^{
NSURL *url_img = [NSURL URLWithString:[artistData objectForKey:pictureKey]];
NSData* data = [NSData dataWithContentsOfURL:
url_img];
cell.imageView.image = [UIImage imageWithData:data];
[self performSelectorOnMainThread:@selector(refreshCell:) withObject:cell waitUntilDone:YES];
});
画像を設定した後、次を含むセレクターを実行します。
-(void)refreshCell:(UITableViewCell*)cell{
[cell setNeedsDisplay];
[self.view setNeedsDisplay];
[self.tableViewOutlet setNeedsDisplay];
}
画像は表示されませんが、セルをクリックするか、リスト全体をスクロールすると、画像が表示されます。ビューが更新されないのはなぜですか? 私は何かを逃しましたか?