如何在iOS中从WebView上的URL获取图像

问题描述 投票:0回答:2

图像代码 - 1wba395mv72m3of2ikz.jpg

我用过这个。

NSURL *imageURL = [NSURL URLWithString:@"http://www.imageurlhost.com/viewer.php?file=1wba395mv72m3of2ikz.jpg"];
NSData *imageData = [NSData dataWithContentsOfURL:imageURL];
UIImage *image = [UIImage imageWithData:imageData];

UIImageView *imgview1 =[[UIImageView alloc]initWithFrame:CGRectMake(0, 0, 150,150 )];

imgview1.image= image;

[scrlview addSubview:imgview1];
ios image url webview fetch
2个回答
0
投票

您可以像这样在图像视图中设置图像

[imageView setImageWithURL:[NSURL URLWithString:@"your url string"] placeholderImage:[UIImage imageNamed:@"Placeholder.png"]];

placeholder.png 是任何临时图像,当收到来自 url 的图像时将被替换


0
投票

Rahul paliwal ...您的网址是 html 页面..如果您想在 imageview 中加载图像,请使用正确的网址... 如果你想在 imagview 中加载图像...就像 这...

enter image description here

© www.soinside.com 2019 - 2024. All rights reserved.