c# - 在 Xamarin/C# 中从 URL 加载的 UIImage

标签 c# ios xamarin.ios uiimage xamarin

this question 已经过去 4 年了已经用 this blog post 回答了.

是否有一种标准方法可以使用来自 URL 的图像创建 UIImage?像这样的东西:

UIImage image = UIImage.FromFile("http://foo.com/bar.jpg");

我觉得我可能遗漏了一些非常简单的东西。

最佳答案

不是单线,但只需很少的几行,您就可以自己滚动。例如

static UIImage FromUrl (string uri)
{
    using (var url = new NSUrl (uri))
    using (var data = NSData.FromUrl (url))
        return UIImage.LoadFromData (data);
}

调用,包括来自 UIImage 的调用,都是线程安全的。

关于c# - 在 Xamarin/C# 中从 URL 加载的 UIImage,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17821371/

相关文章:

c# - LinqToCSV 和十进制全局化

ios - 使用 ObjectiveC++ 编译器的问题

ios - Mono Boehm vs SGen GC

xamarin - 在 AccountStore.Create ().Save (e.Account, ") 处崩溃;

ios - 在设备上调试时应用程序崩溃

c# - 从具有相同代码的列表中选择

c# - 在 Xamarin Forms C# 中发送 HTTP Post 请求

ios - 如何在 iOS 应用程序中显示最近查看的项目(例如 eBay)

c# - 使用 Smo.Backup 将 SQL Server 数据库备份到字符串

ios - 音频队列缓冲区为空错误