首页 文章

Xamarin表单:无法使用FFImageLoading库从URL加载图像

提问于
浏览
0

我正在尝试将图像从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是一个Image小部件,我想将图像从url加载到图像小部件中 .

1 回答

  • 0

    UPDATE:

    使用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是有关如何使用此库的完整文档 .

    希望这可以帮助!

相关问题