【问题标题】:Xamarin Forms: Not able to load image from url using FFImageLoading libraryXamarin Forms:无法使用 FFImageLoading 库从 url 加载图像
【发布时间】:2017-08-03 01:54:16
【问题描述】:

我正在尝试将图像从 url 加载到 xamarin 表单应用程序中的图像视图。但我遇到了一个错误,我没有得到修复。

我正在尝试加载图片,如下所示:

ImageService.Instance
            .LoadFile(imageUrl)
            .LoadingPlaceholder("user.png")
            .Into(btn_profile_pic)
            .Source(btn_profile_pic);

我尝试过只使用 Into 也只使用 Source,但出现以下错误:

String does not contain a definition for Into and no extension method 'Into' accepting a first argument of type during could be found

如果我尝试使用 Source,我会收到以下错误:

Non Invocable member TaskParameter.Source cannot be used like a method

btw_profile_pic 是一个图片小部件,我想将图片从 url 加载到图片小部件中。

【问题讨论】:

    标签: image xamarin xamarin.forms xamarin-studio ffimageloading


    【解决方案1】:

    更新:

    使用 Xamarin 表单:

    XAML

    <ffimageloading:CachedImage
            Source="{Binding imageUrl}"
            LoadingPlaceholder="user.png" />
    

    代码:

    var yourImage = new CachedImage()
    {
        HorizontalOptions = LayoutOptions.FillAndExpand,
        Source = imageUrl,
        Aspect = Aspect.AspectFill,
        LoadingPlaceholder = "user.png"
    };
    

    如您所见,没有 Into() 方法,但您依赖于 CachedImage 类,它将为您完成大部分工作。

    您需要在每个应用程序项目(iOS、Android 和 UWP)中安装相同的 Form 包,并且您需要使用此行来初始化 Renderer。

    CachedImageRenderer.Init();
    

    Here 是有关如何使用此库的完整文档。

    希望这会有所帮助!

    【讨论】:

    • 我的错,抱歉我已经编辑了问题,这是复制粘贴错误。即使添加了括号,我也会得到同样的错误。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2018-07-12
    • 2019-11-14
    • 2018-05-13
    • 1970-01-01
    • 2018-10-22
    • 2020-02-16
    • 1970-01-01
    相关资源
    最近更新 更多