_pageImages是nsmutableArry我存储图像的URL。NSData到uiimage返回null
_pageImages = [[NSMutableArray alloc]initWithObjects:@"https://api.url2png.com/v3/P4DE5D1C99D8EF/7bbb6e0d1b74fb0ae1d4f18b06320096/400x400/abc.com",@"https://api.url2png.com/v3/P4DE5D1C99D8EF/7bbb6e0d1b74fb0ae1d4f18b06320096/400x400/abc.com", nil];
想要在uiimageview中显示此URL图像。
NSURL *url = [NSURL URLWithString:[_pageImages objectAtIndex:i]];
NSData *data = [[NSData alloc] initWithContentsOfURL:url];
UIImage *tmpImage = [UIImage imageWithData:data];
_backgroundImageView.frame = CGRectMake(0 ,10, 320, 320);
_backgroundImageView.image = tmpImage;
[self.view addSubview:_backgroundImageView];
我看到了很多例子,但我不能得到正确的解决方案。新的发展。帮助我..
您是否检查过您的数据不是零?因为也许你只是忘记禁用目标域名的应用传输安全 (当我尝试https://api.url2png.com/v3/P4DE5D1C99D8EF/7bbb6e0d1b74fb0ae1d4f18b06320096/400x400/abc.com我自己,我在浏览器中出现错误...) – CZ54
是的如何使用返回NSError对象的方法(例如'initWithContentsOfURL:options:error:')。 – trojanfoe
你可以在这里找到http://stackoverflow.com/questions/30096806/load-uiimage-from-url-in-ios –