2012-04-03 46 views
0

我是這個iPhone開發的新手。正在開發目錄應用程序。因爲我的圖像來自Web服務,所以我需要將產品圖像的所有產品詳細信息作爲tableview單元格圖像動態顯示。我這樣做,iphone sdk如何動態添加uitableview細胞圖像?

NSString* imageName = [NSString stringWithFormat:@"%@",[[stories objectAtIndex:indexPath.row]objectForKey:@"product_thumb_image"]]; 
cell.imageView.image.size.width==20; 
cell.imageView.image.size.height==20; 
cell.imageView.image = [UIImage imageNamed:imageName]; 
NSLog(@"imagename:%@",[[stories objectAtIndex:indexPath.row]objectForKey:@"product_thumb_image"]); 

我得到我的控制檯窗口中的所有圖像,我檢查使用nslog。但我沒有用模擬器獲得圖像。這是什麼做錯了?你們能幫助我嗎?

在此先感謝。

回答

1

UIImage imageNamed:需要一個NSString,所以如果你想使用的格式化字符串一樣,使用NSString的stringWithFormat

嘗試:

cell.imageView.image = [UIImage imageNamed:[NSString stringWithFormat:@"%@",currentLink]]; 

當你是新的iPhone開發我就展開出使其更清晰(忽略此,如果你已經有了發生了什麼事有)

NSString* imageName = [NSString stringWithFormat:@"%@",currentLink]; 
cell.imageView.image = [UIImage imageNamed:imageName]; 
0

操作步驟如下:

NSString *imageName = [NSString stringWithFormat:@"%@",currentLink]; 
cell.imageView.image = [UIImage imageNamed:imageName]; 
0

Apple文檔包含將下載的圖像放入表格單元的示例。它被稱爲LazyTableImages,可能會幫助您嘗試做什麼。