0

UIImageView は画像を取得せず、null を返します。遅延コードも試しましたが、それでも null が返されます。

UIImageView *image_view=[[UIImageView alloc]initWithFrame:CGRectMake(10, 2, 50, 58)];

  NSString *StrImg=[[NSString alloc]init];

  StrImg=[NSString stringWithFormat:@"%@",[[Array_FinalobjectAtIndex:indexPath.row]objectForKey:@"coverphoto"]];

  NSLog(@"StrImg value=%@",StrImg);

 [image_view setImageWithURL:[NSURL URLWithString:StrImg] placeholderImage:[UIImage imageNamed:@"star.png"] success:^(UIImage *image) {}failure:^(NSError *error){}];
4

3 に答える 3

0

iCarousel の父である Nicklockwood による美しい実装である AsyncImageView を使用することをお勧めします。

https://github.com/nicklockwood/AsyncImageView

使い方はとても簡単です。

    #import "AsyncImageView.h"

そしてすべてのimageViewsでこれを行います。

    [imageView setImage:@"default.png"];
    [imageView setImageURL:@"whateverurl/whateverimage.png"];

それは魔法のように機能し、私のコードは実稼働中です。

于 2013-04-04T07:14:54.667 に答える