0

UITableView の奇妙な動作に気付きました。

TableViews ImageView にサムネイル画像を表示したい。画像はクライアント サーバーにあり、この画像へのリンクは XML ファイルで取得されます。XML パーサーから URL を取得し、そのリンクからイメージを ImageView に表示しようとすると、期待した結果が得られません。TableViews ImageView は空のままです。

NSString * imagePath = [[self.parseResults objectAtIndex:indexPath.row] objectForKey:@"imagelink"];

NSURL * imageURL = [NSURL URLWithString:imagePath];
NSData * imageData = [NSData dataWithContentsOfURL:imageURL];
UIImage * image = [UIImage imageWithData:imageData];

cell.imageView.image = image;


return cell;

ただし、URL をハードコーディングすると、問題なく動作します。

NSString * imagePath = @"http://www.test.com/test.jpg";

NSURL * imageURL = [NSURL URLWithString:imagePath];
NSData * imageData = [NSData dataWithContentsOfURL:imageURL];
UIImage * image = [UIImage imageWithData:imageData];

cell.imageView.image = image;


return cell; 

これにより、イメージが ImageView に表示されます。

NSLog を使用して URL を比較しましたが、違いはわかりませんでした。ただし、文字列比較を行うと、リンクが異なるようです。

特別なエンコーディングなどはありますか?

ご協力いただきありがとうございます!

4

0 に答える 0