2012-01-17 64 views
0

因此,我正在編寫一個應用程序,並從網站網址獲取專輯圖稿。UITableView在應用程序加載後加載圖像

基本上我迄今寫的是如何讀入一個文件,其中包含專輯封面的URL。然後,使用文件中的數據構建二維NSMutableArray,並從文件中的單個URL初始化UIImages,然後將其存儲在數組中。

然後將該數組加載到UITableView中。

這很好用...除了它需要像加載應用程序(lol)10秒鐘。

那麼一旦加載UITableView,有什麼方法來加載圖像?

這是我的cellForRowAtIndexPath方法,如果有幫助。

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { 

UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"identifier"]; 

if (cell == nil) { 
     cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:@"identifier"]autorelease]; 
} 

((UILabel *)[cell viewWithTag:artistTag]).text = [[musicList.list objectAtIndex:indexPath.row] objectAtIndex:artistIndex]; 

((UILabel *)[cell viewWithTag:albumTag]).text = [[musicList.list objectAtIndex:indexPath.row] objectAtIndex:albumIndex]; 

((UILabel *)[cell viewWithTag:dateTag]).text = [[musicList.list objectAtIndex:indexPath.row] objectAtIndex:dateIndex]; 

((UIImageView *)[cell viewWithTag:imageTag]).image = [[musicList.list objectAtIndex:indexPath.row] objectAtIndex:imageIndex]; 

return cell; 

}

非常感謝!

回答

0

你真正想要做的是加載圖像在後臺線程樣本。

對於相關的代碼全套,檢查出SDWebImage

或者只是異步查看代碼,結賬this link