2010-07-03 85 views
0

我的iPhone應用程序圖像在表格單元右側從xml提取中提取。知道我想以固定大小顯示它們,任何人都可以幫助我。 波紋管是代碼如何在自定義單元格中顯示自定義大小的圖像

int blogEntryIndex1 = [indexPath indexAtPosition: [indexPath length] -1]; 
    imgstring=[[blogEntries objectAtIndex: blogEntryIndex1] objectForKey: @"image"]; 
    NSURL *url = [NSURL URLWithString:imgstring]; 
     NSData *data = [NSData dataWithContentsOfURL:url]; 
     UIImage *img = [[UIImage alloc] initWithData:data]; 
      cell.imageView.image=img; 
     cell.textLabel.text=headline; 

在此先感謝,我將等待

回答

1

設置您的UIImageView的內容模式UIViewContentModeScaleAspectFit或UIViewContentModeCenter如果你的圖片不需要任何縮放。

[yourImageView setContentMode:UIViewContentModeScaleAspectFit]; 

查看API中的示例。有一種更好的方式來爲表格視圖單元格加載圖像。 http://developer.apple.com/iphone/library/samplecode/LazyTableImages

而且爲了更好地理解表視圖細胞的解剖閱讀: http://developer.apple.com/iphone/library/documentation/UserExperience/Conceptual/TableView_iPhone/TableViewCells/TableViewCells.html