1

SDWebImage を使用して、SQL からテーブル ビュー セルに複数の画像を設定しようとしています。

私は現在このコードを使用していますが、これは URL に基づいて 1 つの画像をロードします。

[cell.imageView setImageWithURL:[NSURL URLWithString:@"http://www.domain.com/path/to/image.jpg"]
                   placeholderImage:[UIImage imageNamed:@"placeholder.png"]];

複数の画像の imageView をどのように設定しますか? ありがとう。

forループを使ってみました。動作しません。

NSArray *itmImageArray = [self itemImages];

    for(int i = 0; i <= [itmImageArray count]; i++)
    {
        [cell.imageView setImageWithURL:[NSURL URLWithString:@"http://www.domain.com/path/to/%@",[itmImageArray objectAtIndex:i]]
                   placeholderImage:[UIImage imageNamed:@"addnewimage.png"]];
    }
4

1 に答える 1

0

A UITableViewCell has only one imageView. The technique you are using will keep resetting the same imageView that a UITableViewCell has by default and what you will see is the last image of your for loop set in the cell. If you want to display more images you will have to create a custom cell and add multiple UIImageViews as subviews of the cell. You can then set different images into the UIImageViews you add. Remember, you will have to handle the frames of UIImageViews as well as height of the tableView row so that the content is displayed properly.

于 2012-10-26T19:46:40.463 に答える