【问题标题】:Xamarin Forms FFImageLoading Image not showingXamarin Forms FFImageLoading 图像未显示
【发布时间】:2017-09-01 13:13:31
【问题描述】:

我正在尝试在我们的一个 Xamarin Forms 项目中使用 FFImageLoading,但我遇到了一些奇怪的问题。

当我尝试将 Sources="anyvalidimageurl" 放在 XAML 上时,我收到此错误:

无效的 XAML:值不能为空。参数名称:'obj'

这是 XAML:

<ffimageloading:CachedImage HorizontalOptions="Center" 
            WidthRequest="300" 
            HeightRequest="300"
            DownsampleToViewSize="true"
            Source="http://myimage.com/image.png"
            x:Name="imgImage">
</ffimageloading:CachedImage>

我尝试通过代码加载图片,但iOS上没有显示图片。

【问题讨论】:

  • 您的 iOS 项目是否设置为允许 http 请求?
  • NSAppTransportSecurityNSAllowsArbitraryLoads IOS默认禁用http请求

标签: ios xaml xamarin xamarin.forms ffimageloading


【解决方案1】:

您需要将此添加到您的 AppDelegate.cs

  public override bool FinishedLaunching(UIApplication app, NSDictionary options)
    {
        FFImageLoading.Forms.Touch.CachedImageRenderer.Init();
        var dummy = new FFImageLoading.Forms.Touch.CachedImageRenderer();

        global::Xamarin.Forms.Forms.Init();
        LoadApplication(new App());

        return base.FinishedLaunching(app, options);
    }

欲了解更多信息,请参阅https://github.com/luberda-molinet/FFImageLoading/issues/55

【讨论】:

    【解决方案2】:

    您是否错过了包含 CachedImageRenderer.Init();在 AppDelegate.cs 中

    【讨论】: