2011-03-09 100 views
1

在我的iPhone應用程序中,我有一個UITabelview通過URL填充數據。當我從UITableview中選擇一個單元格時,它會調用URL並下載圖像並傳遞給另一個UITableview。當我單擊單元格時,需要一段時間才能加載圖像並保持單擊UITableviewcell。我有以下代碼調用URL並在每個單元格調用中加載圖像。從UIImageView的UIActivityIndi​​catorView的URL加載圖像

if (!cell) { 
     cell = [[[UITableViewCell alloc] initWithFrame:CGRectZero reuseIdentifier:@"imageCell"] autorelease]; 
     imageView1 = [[cell subviews] lastObject]; 
     [cell addSubview:imageView1 ]; 
} 

NSString fileName = image.Img; 
NSString *filePath= [NSString stringWithFormat:@"http://www.abc.com/xml/id=12345",fileName]; 

UIImage *im = [UIImage imageWithData: [NSData dataWithContentsOfURL:[NSURL URLWithString:filePath]]]; 
subview = [[UIImageView alloc] initWithFrame:CGRectMake(120.0f, 10.0f,60.0f, 60.0f)] ; 
[subview setImage:im]; 
[subview setContentMode:UIViewContentModeScaleToFill]; 
[cell.contentView addSubview:subview]; 

我看到其中的個人資料相片是越來越下載並在它的數據UIActivityIndi​​cator加載幾個應用程序。我想以相同的方式在UIImageView上使用UIActivityIndi​​cator。任何人都可以幫助我在uiimageview上實現uiactivityindicator。

回答

0
+0

感謝您的搜索。但我還有一個擔心,一旦數據被下載,我應該如何在詳細視圖控制器頁面上顯示它。我已經使用這個代碼背後的邏輯:https://github.com/slatvick/Alterplay-iPhone-dev-tips/blob/gh-pages/AsyncImage/AsynchronousImageView.m – lifemoveson 2011-03-09 23:18:38

相關問題