gpt4 book ai didi

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

转载 作者:行者123 更新时间:2023-11-28 21:15:46 25 4
gpt4 key购买 nike

我目前在自定义数据模板内的 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/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com