【发布时间】:2020-10-28 13:06:18
【问题描述】:
我正在使用 Xamarin.Forms 开发企业应用程序。我在 iOS 中特别面临内存泄漏问题(在 Android 中运行良好)。
关于单击列表视图项目标题,我实现了手势,然后还实现了一个透明按钮,但它会导致内存泄漏 - 即使我注释掉它的功能。
如果我评论 testbutton 那么它的对象可以正常处理。我可以做些什么来解决这个问题?
```
<ListView
Style="{DynamicResource BaseListViewStyle}"
IsGroupingEnabled="True"
ItemsSource="{Binding Deliveries.ExpandedDeliveryItemModels}"
IsPullToRefreshEnabled="True"
IsRefreshing="{Binding Deliveries.IsRefreshing}"
RefreshCommand="{Binding RefreshCommand}"
SelectionMode="None">
<ListView.GroupHeaderTemplate>
<DataTemplate>
<ViewCell AutomationId="headerCell">
<StackLayout AutomationId="headerLayout" Orientation="Horizontal">
<Label Text="{Binding HeaderTitle}"
AutomationId="DeliveriesToday"
HorizontalOptions="StartAndExpand">
</Label>
<Button x:Name="testbutton"
HorizontalOptions="End"
Command="{Binding Source={x:Reference deliveriesPage}, Path=BindingContext.HeaderClickCommand}"
CommandParameter="{Binding .}">
</Button>
</StackLayout>
</ViewCell>
</DataTemplate>
</ListView.GroupHeaderTemplate>
<ListView.ItemTemplate>
<DataTemplate>
<ViewCell AutomationId="deliveriesCell">
<Label Text="Testing"></Label>
</ViewCell>
</DataTemplate>
</ListView.ItemTemplate>
</ListView>
```
【问题讨论】:
标签: xamarin xamarin.forms xamarin.ios xamarin-studio xamarin.forms.listview