0

NSXMLParser を使用して XML ファイルを解析しています。セルの数は、XML ファイルのエントリ数によって異なります。これはすべてうまくいきます。

ここで、(XML ファイルで宣言された) URL をロードしたいプロトタイプ セルに UIImageView を追加しました。

ストーリーボード エラー: 接続をコンパイルできませんでした..

プロトタイプセルのせいだとわかっています。しかし、XML とは異なる画像を表示できるすべてのセルに UIImageView を追加するにはどうすればよいでしょうか?

編集:

Heres 私のコードですが、これは重要ではありません..Interface Builder で UIImageView を接続するたびに、エラーが表示されます..

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

static NSString *CellIdentifier = @"productCell";

UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
    cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier];
}

XMLProductView *listedProduct = [appDelegate.products objectAtIndex:indexPath.row];

/*
NSOperationQueue *queue = [NSOperationQueue new];
NSInvocationOperation *operation = [[NSInvocationOperation alloc] init];
[queue addOperation:operation];
*/

NSString *imageURL = listedProduct.image;

NSData *imageData = [[NSData alloc] initWithContentsOfURL:[NSURL URLWithString:imageURL]];

UIImage *image = [UIImage imageWithData:imageData];

[imageView setImage:image];

cell.textLabel.text = listedProduct.name;
cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;

return cell;

}

4

1 に答える 1

1

多分あなたのimageViewはアウトレットですか?プロトタイプセルには配線しないでください。プログラムにimageViewを追加できます:

 [cell addSubview:imageView];

または、ストーリーボードで imageView を作成し、それを取得します。

 [cell viewWithTag:theTagOfImageView];

編集 2

本当に必要なものだと思います。幸運を!

LazyTableImages

于 2012-05-31T19:35:13.257 に答える