我在我的应用程序中使用了以下代码。
string imageUrl = "https://imageUrl.png/"; //This is a valid url. I can see the image when I paste the url into my web browser
var url = new NSUrl(imageUrl);
using (CGImageSource source = CGImageSource.FromUrl(url))
{
if (source != null)
{
//I never get here
}
}为什么source总是为空?我尝试了许多不同的imageUrls,结果都是一样的。
发布于 2018-08-16 10:34:13
您的照片地址似乎是HTTPS不同于HTTP.You可以尝试另一个prefix.which是HTTPS地址必须是HTTPS,我建议您使用一些prefix.If。
或者您可以使用以下代码,它们在使用http时有效
string str = ""; //your image url
NSData ImageData = NSData.FromUrl(new NSUrl(str) );
UIImage image = new UIImage(ImageData);
if (image != null)
{
Console.Write("success");
}
else
{
Console.Write("fail");
}https://stackoverflow.com/questions/51865115
复制相似问题