【问题标题】:Xamarin Image SourceXamarin 图像源
【发布时间】:2019-12-18 05:24:08
【问题描述】:

如果之前有人问过这个问题,我们深表歉意。

我有一个相当简单的问题,我想知道我是否遗漏了一些明显的东西。在我的实践 Xamarin.Forms 应用程序中,我在加载以下图像源 URI 时遇到问题:http://lorempixel.com/1920/1080/sports/7/,即使当我通过浏览器去那里时;没事。

在我看来,Xamarin 需要一个图像扩展才能工作,所以例如,如果我要在网上有某种图像,例如 (https://www.stickpng.com/assets/images/58b061138a4b5bbbc8492951.png,公平警告;如果你去,这个链接将下载猫图像到它)然后它加载正常。

我的问题有两个:我的配置中是否缺少一些需要启用的简单内容(这是针对 Android 的,因为我没有可用的 iOS 设备 atm),以及 B:xamarin 甚至支持相对路径吗?

代码背后:

var source = new UriImageSource 
{ 
    Uri = new Uri("http://lorempixel.com/1920/1080/sports/7/")
};

source.CachingEnabled = false;

ImageOne.Source = source;

【问题讨论】:

  • 尝试使用https://lorempixel.com/1920/1080/sports/7/
  • @Jason 成功了!所以我想它需要 https 来代替

标签: c# xamarin xamarin.forms


【解决方案1】:

说明

iOS 和 Android 现在都需要https

回答

这应该很容易解决 - 将 http 更改为 https

var source = new UriImageSource 
{ 
    Uri = new Uri("https://lorempixel.com/1920/1080/sports/7/")
};

source.CachingEnabled = false;

ImageOne.Source = source;

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2017-08-22
    • 2017-08-23
    • 2017-08-18
    • 1970-01-01
    • 1970-01-01
    • 2017-06-26
    • 1970-01-01
    相关资源
    最近更新 更多