我使用了FlowListView,但在iOS中无法正常工作?

时间:2019-12-25 10:00:55

标签: c# xamarin xamarin.forms xamarin.ios

我已经为画廊视图创建了一个示例。为此,我使用了flowlistview nuget。在Android上运行正常,但在iOS上网格中显示了一个奇怪的箭头。有想法吗?

UserPhotos.xaml

<?xml version="1.0" encoding="UTF-8" ?>
<ContentPage
    xmlns="http://xamarin.com/schemas/2014/forms"
    xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
    xmlns:flv="clr-namespace:DLToolkit.Forms.Controls;assembly=DLToolkit.Forms.Controls.FlowListView"
    x:Class="MyApp.UserPhotos"
    Title="Photos">

    <ContentPage.Content>
        <StackLayout Padding="10" Margin="5">
            <flv:FlowListView 
                HasUnevenRows="True"
                FlowColumnCount="2"
                FlowItemTappedCommand="{Binding ItemTappedCommand}"
                SeparatorVisibility="Default"
                FlowItemsSource="{Binding userAlbumsList}">

                <flv:FlowListView.FlowColumnTemplate>
                    <DataTemplate>
                        <Frame x:Name="itemTemp"
                               Margin="5"
                               CornerRadius="5"
                               BackgroundColor="#5d6d20"
                               HorizontalOptions="FillAndExpand"
                               VerticalOptions="FillAndExpand">
                            <StackLayout Padding="0,8,0,8"
                                         VerticalOptions="Center"
                                         HorizontalOptions="Center">
                                <Image Aspect="AspectFit"
                                       HeightRequest="60"
                                       WidthRequest="60"
                                       Source="album.png"
                                       HorizontalOptions="CenterAndExpand"
                                       VerticalOptions="CenterAndExpand" />
                            </StackLayout>
                        </Frame>
                    </DataTemplate>
                </flv:FlowListView.FlowColumnTemplate>

            </flv:FlowListView>
        </StackLayout>
    </ContentPage.Content>

</ContentPage>

Output:

1 个答案:

答案 0 :(得分:1)

您可以使用 CustomRenderer 设置iOS中单元格的附件

using MyApp.iOS;
using Xamarin.Forms;
using Xamarin.Forms.Platform.iOS;

[assembly: ExportRenderer(typeof(ViewCell), typeof(StandardViewCellRenderer))]
namespace MyApp.iOS
{
    public class StandardViewCellRenderer : ViewCellRenderer
    {

        public override UIKit.UITableViewCell GetCell(Cell item, UIKit.UITableViewCell reusableCell, UIKit.UITableView tv)
        {
            var cell = base.GetCell(item, reusableCell, tv);
            switch (item.StyleId)
            {
                case "none":
                    cell.SelectionStyle = UIKit.UITableViewCellSelectionStyle.None;
                    break;
                case "checkmark":
                    cell.Accessory = UIKit.UITableViewCellAccessory.Checkmark;
                    break;
                case "detail-button":
                    cell.Accessory = UIKit.UITableViewCellAccessory.DetailButton;
                    break;
                case "detail-disclosure-button":
                    cell.Accessory = UIKit.UITableViewCellAccessory.DetailDisclosureButton;
                    break;
                case "disclosure":
                default:
                    cell.Accessory = UIKit.UITableViewCellAccessory.None;
                    break;
            }
            return cell;


        }
    }

}