0

我目前在自定义数据模板内的 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 将显示图像。

我真的需要它来减小图像大小。你们有没有人遇到过这个问题。

4

2 回答 2

2

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

改变

<Image>...</Image>

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

还要添加命名空间

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

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

哎呀忘了提,您还需要添加 DownsampleHeight 或 DownsampleWidth 以减小大小。

于 2016-12-27T17:59:37.280 回答
0

正在尝试通过http而不是https下载图像吗?

您需要将以下内容添加到您的 info.plist

<key>NSAppTransportSecurity</key>
<dict>
  <!--Include to allow all connections (DANGER)-->
  <key>NSAllowsArbitraryLoads</key>
      <true/>
</dict>
于 2016-12-29T13:01:30.800 回答