在我在專案中的所有串列視圖之上,在 ios 平臺上有一個空白區域,在 android 或 windows 上沒有這樣的問題。
截屏:

我的代碼:
<ListView
x:Name="MyItems"
RefreshCommand="{Binding RefreshCommand}"
IsPullToRefreshEnabled="True"
IsRefreshing="{Binding IsRefreshing}"
HasUnevenRows="True">
<ListView.ItemTemplate>
<DataTemplate>
<ViewCell>
<ViewCell.View>
<StackLayout
Orientation="Vertical">
<StackLayout
HorizontalOptions="FillAndExpand"
VerticalOptions="FillAndExpand"
Orientation="Horizontal">
</StackLayout>
</StackLayout>
</ViewCell.View>
</ViewCell>
</DataTemplate>
</ListView.ItemTemplate>
<ListView.Footer>
<Label/>
</ListView.Footer>
</ListView>
額外細節:
XF 版本:4.8.0.1821
專案型別為便攜式
uj5u.com熱心網友回復:
請參閱此執行緒:https ://developer.apple.com/forums/thread/683980 。
為了解決這個問題,我們可以為 ListView 添加一個自定義渲染器
試試下面的代碼:
[assembly: ExportRenderer(typeof(ListView), typeof(LVRenderer))]
namespace YourNameSpace.iOS
{
public class LVRenderer : ListViewRenderer
{
public LVRenderer()
{
}
protected override void OnElementChanged(ElementChangedEventArgs<ListView> e)
{
base.OnElementChanged(e);
if (Control != null)
{
Control.SectionHeaderTopPadding = new nfloat(0);
}
}
}
}
在這里找到它:
將 iOS 更新到 15 后串列視圖頂部的奇怪空間
轉載請註明出處,本文鏈接:https://www.uj5u.com/gongcheng/447452.html
標籤:IOS 列表显示 xamarin.forms
上一篇:如何洗掉WPFListView右側的額外空白空間(列)
下一篇:Tabview滾動行為
