无法将图像加载到UIImage中

时间:2013-01-30 01:31:57

标签: objective-c xcode ios6 uiimage

我在Amazon S3服务上有两张图片。一个加载好,另一个不加载。没有错误消息。它只是不加载。

[doodleImageView setImageWithURL:@"https://s3.amazonaws.com/doodlestash/doodles/20/thumb.jpg"];

 //This one does not load.
[doodleImageView setImageWithURL:@"https://s3.amazonaws.com/doodlestash/doodles/20/original.jpg"];

有什么想法?

1 个答案:

答案 0 :(得分:1)

图像看起来都是“有效的”。您可能需要仔细检查您正在使用的库并检查拼写错误。在快速演示应用程序中,我执行了以下操作:

- (void)viewDidLoad
{
    [super viewDidLoad];
    // Do any additional setup after loading the view, typically from a nib.

    UIImageView* image1 = [[UIImageView alloc]initWithFrame:CGRectMake(0, 0, 320, 200)];
    image1.image = [UIImage imageWithData: [NSData dataWithContentsOfURL:[NSURL URLWithString:@"https://s3.amazonaws.com/doodlestash/doodles/20/original.jpg"]]];

    UIImageView* image2 = [[UIImageView alloc]initWithFrame:CGRectMake(0, 200, 320, 200)];
    image2.image = [UIImage imageWithData: [NSData dataWithContentsOfURL:[NSURL URLWithString:@"https://s3.amazonaws.com/doodlestash/doodles/20/thumb.jpg"]]];

    [self.view addSubview:image1];
    [self.view addSubview:image2];
}

我最终得到了这个:

enter image description here