ios - Xamarin:FFImageLoading 不显示在 iOS 上使用内部 ListView

标签 ios image xamarin image-loading ffimageloading

我目前在自定义数据模板内的 listView 上使用 FFImageLoading 库。

<ListView.ItemTemplate>
                    <DataTemplate>
                        <ViewCell>
                            <ViewCell.ContextActions>
                                <MenuItem Clicked="OnDelete" CommandParameter="{Binding .}" Text="Delete" IsDestructive="True" />
                            </ViewCell.ContextActions>
                            <StackLayout
                                Padding="12,10,12,10" 
                                BackgroundColor="Transparent"
                                Orientation="Horizontal">
                                <Image
                                    DownsampleToViewSize="true"
                                    Aspect="AspectFit"
                                    Source="{Binding FileThumbnail, Converter={StaticResource mimeTypeToImageConverter}}"
                                    WidthRequest="60"
                                    HeightRequest="60">
                                </Image>

在 mimeTypeToImageConverter 内部:

public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
    {
        if (value is string)
        {
            var file = (string)value;     

            if (FileUtilities.IsImageType(file))
            {
                //var fileImageSource = new FileImageSource();
                //fileImageSource.File = file;
                var imageSource = ImageSource.FromFile(file);
                return imageSource;
            } 
            else {
                return ImageSource.FromFile("ic_file_white.png");
            }

        } 
        return null;
    }

我在 android 上使用过,但 android 工作正常。当我改回图像控件时,iOS 将显示图像。

我真的需要它来减小图像尺寸。你们以前有没有遇到过这个问题。

最佳答案

您需要使用 FFImageLoading 控件而不是使用图像控件

改变

<Image>...</Image>

<forms:CachedImage>...</forms:CachedImage>

同时添加命名空间

<ContentPage xmlns:forms="clr-namespace:FFImageLoading.Forms;assembly=FFImageLoading.Forms">

CachedImage 应具有与 Image 相同的所有属性

糟糕,忘了说,您还需要添加 DownsampleHeight 或 DownsampleWidth 来减小尺寸。

关于ios - Xamarin:FFImageLoading 不显示在 iOS 上使用内部 ListView ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41345608/

相关文章:

jquery - 如果我的范围 slider = 0.5,如何更改按钮图像? (js)

c# - Xamarin 上的 WebHeaderCollection 和 HttpWebRequest

c# - Android - 在 ListView 项目点击时打开开关 "On"

c# - 我们可以在 ScrollView Xamarin.Forms 中隐藏滚动条吗

ios - 注销时 Firebase 给出异常

ios - 当应用程序在后台时,AVAssetReader 将无法正确初始化,因此无法开始阅读

ios - React Native v0.61.5 获取 ITMS-90809 : Depracated API Usage

ios - Swift - self.tableview.reloaddata() 不适用于主详细信息应用程序

iphone - UIWebView 上具有大图像尺寸的 img src 需要时间加载,有时会崩溃

css - 缓存背景图片