只有當我開始滾動UITableView時,從url下載的圖像纔會在UITableViewCell中顯示圖像。現在我使用以下代碼從url加載圖片:只有當我滾動表格視圖時,纔會加載來自UITableViewCell中url的圖像
NSURL* url = [NSURL URLWithString:imageURL];
NSURLRequest* request = [NSURLRequest requestWithURL:url];
[NSURLConnection sendAsynchronousRequest:request
queue:[NSOperationQueue mainQueue]
completionHandler:^(NSURLResponse * response,
NSData * data,
NSError * error) {
if (!error){
NSImage* image = [[NSImage alloc] initWithData:data];
// do whatever you want with image
}
}];
在此先感謝。
你從哪裏調用這段代碼?你可以添加你的tableView更新方法嗎? – Craig 2014-09-27 07:10:53
我在單元格中爲indexpath中的行使用此代碼。 – Arun 2014-09-27 07:12:29