我在Xaml中有一个视图,我正在尝试按以下方式使用集合视图
<CollectionView
x:Name="ColorCollectionView"
Margin="5"
HeightRequest="250"
WidthRequest="250"
ItemSizingStrategy="MeasureFirstItem"
ItemsSource="{Binding Categories}"
SelectedItem="{Binding SelectedCategory, Mode=OneWayToSource}"
SelectionChangedCommand="{Binding SelectedItemChangedCommand}"
SelectionChangedCommandParameter="{Binding Source={x:Reference ColorCollectionView}, Path=SelectedItem}"
SelectionMode="Single"
VerticalOptions="Center">
<CollectionView.ItemsLayout>
<GridItemsLayout Orientation="Horizontal" Span="2"
</CollectionView.ItemsLayout>
<CollectionView.ItemTemplate>
<DataTemplate>
<StackLayout Padding="20,0" Spacing="0">
<Frame Padding="10"
BackgroundColor="White"
BorderColor="{Binding
BackgroundSelectedColor}"
CornerRadius="100"
HasShadow="False">
<Image HeightRequest="60" Source="{Binding Image}"WidthRequest="60"/>
</Frame>
<Label FontFamily="{x:Static constants:Fonts.Medium}" FontSize="12" HorizontalOptions="Center" Text="{Binding Name}" TextColor="Black" /
</StackLayout>
</DataTemplate>
</CollectionView.ItemTemplate>
</CollectionView>
它在android中工作正常,但是我在iOSd中遇到了这个异常
Managed Stacktrace:
at <unknown> <0xffffffff>
at ObjCRuntime.Messaging:nint_objc_msgSend_nint <0x0011f>
at UIKit.UICollectionView:NumberOfItemsInSection <0x0017a>
at Xamarin.Forms.Platform.iOS.GridViewLayout:NeedsPartialColumnAdjustment <0x00282> at
Xamarin.Forms.Platform.iOS.GridViewLayout:get_CollectionViewContentSize