セル内に画像を表示する方法?
-
19-09-2019 - |
質問
私はout.Thanks私を助けてarray.pleaseにおける画像のURLのみを持っています各cell.Iで画像を表示したいiphoneのdevelopment.Iに新しいです。
解決
//put this code in cellForRowAtIndexPath.... I'm assuming you have an array of url's that point to images
id urlPath = [yourArray objectAtIndex:indexOfImage];
NSURL *url = [NSURL URLWithString:urlPath];
NSData *data = [NSData dataWithContentsOfURL:url];
UIImage *image = [UIImage imageWithData:data];
static NSString *CellIdentifier = @"Cell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier] autorelease];
}
//insert an image into your cell
cell.imageView = image;
は、おそらくこれを行うには、より効率的な方法がありますが、それはあなたのテーブルビューのセルをカスタマイズ始めるためにまともな方法です。 ImageViewのは、UITableViewCellのクラスの多くの特性の一つである。
また読み出し.... のUITableViewCellクラスリファレンスの
他のヒント
あなたはこのAppleのサンプルコードを見てみる必要があり、それは素晴らしいですし、あなたが必要とプラス他の有用なもの何を実装する方法を示しています。 高度な表の表示セルの
所属していません StackOverflow