StackLayout Tableview 切断半屏,但仅限于发布模式

问题描述

我的 Tableview 出现了一些奇怪的问题。 它切断了半屏,但当我进入调试模式时,它工作正常。

我正在使用 AbsoluteLayout 但我填满了整个屏幕,至少是我认为的那样。

不过只有在这页面上,所有其他页面看起来都不错。这是我使用的唯一页面 Tableview 不确定这是否相关。仅发生在 iOS 上,它会影响我直接从 Visual Studio 下载它以及通过 App 中心分发它时,因此在这种情况下,我认为它不是模拟器或 Visual Studio。有什么想法吗?

<ContentPage xmlns="http://xamarin.com/schemas/2014/forms"
             xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml" 
             x:Class="Example123.MoreContentPage"
             xmlns:local="clr-namespace:Example123.MarkupExtensions"
             Title="More Settings">
    <ContentPage.Content>
        <AbsoluteLayout>
             <StackLayout Padding="5" AbsoluteLayout.LayoutBounds="0,1,1" AbsoluteLayout.LayoutFlags="All">
                <TableView x:Name="MoreTable"
                           HasUnevenRows="True"
                           HorizontalOptions="FillAndExpand"
                           VerticalOptions="FillAndExpand">
                    <TableRoot>  
                       <TableSection>
                        <ViewCell>
                            <StackLayout Orientation="Horizontal"
                                        BackgroundColor="#f7f7fb">
                                <Label Text="Preferences"
                                    VerticalOptions="Center"
                                    Margin="15,5,5"
                                    FontSize="17"
                                    Padding="10"
                                    TextColor="#000"
                                    FontAttributes="Bold"/>       
                            </StackLayout>     
                        </ViewCell>
                        <ViewCell Tapped="OpenFontSizing">
                                <StackLayout Orientation="Horizontal" Margin="10">
                                    <Image Source="settings.png"
                                        Margin="10,10,10"
                                        WidthRequest="23"/>
                                    <Label Text="App Settings - Adjust text Size"
                                        VerticalTextAlignment="Center"
                                        Margin="15,5"
                                        Padding="2"
                                        x:Name="label1"/>       
                                </StackLayout>
                         </ViewCell>
                        <ViewCell>
                            <StackLayout Orientation="Horizontal">
                                    <Label Text="Terms of Use"
                                        VerticalOptions="Center"
                                        Margin="15,5"
                                        FontSize="17"
                                        Padding="10"
                                        TextColor="#000"
                                        FontAttributes="Bold"/>
                                </StackLayout>     
                        </ViewCell>
                        <ViewCell Tapped="OpenTermsandConditions">
                            <StackLayout Orientation="Horizontal" Margin="10">
                                <Image Source="accept.png" WidthRequest="23"  Margin="10,10"/>
                                <Label Text="Terms of Use"
                                        Margin="15,5"
                                    Padding="2"
                                    VerticalTextAlignment="Center"
                                    FontSize="{Binding H2Font}"
                                    TextColor="#5e5e5e"/>       
                            </StackLayout>       
                        </ViewCell>
                        <ViewCell Tapped="DownloadRedirect">
                            <StackLayout Orientation="Horizontal" Margin="10">
                                <Image Source="download.png" Margin="10,10" WidthRequest="23"/>
                                <Label Text="Download our App!"
                                    VerticalOptions="CenterandExpand"
                                    Margin="15,5"
                                    Padding="2"
                                    VerticalTextAlignment="Center"
                                    LineBreakMode="WordWrap"
                                    x:Name="label2"/>       
                            </StackLayout>       
                        </ViewCell>
                        <ViewCell>
                            <StackLayout Orientation="Horizontal">
                                    <Label Text="Contact Specialty"
                                        VerticalOptions="Center"
                                        Margin="15,5"
                                        Padding="10"
                                        FontSize="17"
                                        TextColor="#000"
                                        FontAttributes="Bold"/>       
                                </StackLayout>     
                        </ViewCell>
                            <ViewCell Tapped="SendEmail">
                                <StackLayout Orientation="Horizontal" Margin="10">
                                    <Image Source="envelope.png"  Margin="10,10" WidthRequest="23"/>
                                    <Label Text="Feedback or Questions"
                                        VerticalOptions="Center"
                                        Margin="15,5"
                                        VerticalTextAlignment="Center"
                                        Padding="2"
                                        x:Name="label3"/>       
                                </StackLayout>       
                            </ViewCell>
                        <ViewCell>
                            <StackLayout Orientation="Horizontal">
                                    <Label Text="News"
                                        VerticalOptions="Center"
                                        Margin="15,5"
                                        Padding="10"
                                        FontSize="17"
                                        TextColor="#000"
                                        FontAttributes="Bold"/>       
                                </StackLayout>     
                        </ViewCell>
                        <ViewCell Tapped="TWRedirect">
                            <StackLayout Orientation="Horizontal" Margin="10">
                                <Image Source="twitterFinal.png"  Margin="10,10"
                                    WidthRequest="23" />
                                <Label Text="Product News"
                                    VerticalOptions="Center"
                                    Margin="15,5"
                                    VerticalTextAlignment="Center"
                                    Padding="2"
                                   x:Name="label4"/>       
                            </StackLayout>       
                        </ViewCell>
                        <ViewCell>
                            <StackLayout Orientation="Horizontal">
                                    <Label Text="Share Market®"
                                        VerticalOptions="Center"
                                        Margin="15,5"
                                        FontSize="17"
                                        Padding="10"
                                        TextColor="#000"
                                        FontAttributes="Bold"/>       
                                </StackLayout>     
                        </ViewCell>
                   
                        <ViewCell Tapped="SeasonalRedirect">
                            <StackLayout Orientation="Horizontal" Margin="10">
                                <Image Source="search_share.png"  Margin="10,10"
                                    WidthRequest="23"  />
                                <Label Text="In Season Now! List"
                                    VerticalOptions="Center"
                                    Margin="15,5"
                                    VerticalTextAlignment="Center"
                                    Padding="2"
                                    x:Name="label5"/>       
                            </StackLayout>       
                        </ViewCell>
                        <ViewCell Tapped="SMRedirect">
                                <StackLayout Orientation="Horizontal" Margin="10">
                                    <Image Source="add.png"  Margin="10,10" WidthRequest="23"  />
                                    <Label Text="Sign up for Share Market® HIghlights Newsletter"
                                        VerticalOptions="Center"
                                        Margin="15,5"
                                        VerticalTextAlignment="Center"
                                        Padding="2"
                                        x:Name="label6"/>       
                                </StackLayout>       
                        </ViewCell>
                        <ViewCell>
                            <StackLayout Orientation="Horizontal">
                                    <Label Text="Social Networks"
                                        VerticalOptions="Center"
                                        Margin="15,5"
                                        Padding="10"
                                        FontSize="17"
                                        TextColor="#000"
                                        FontAttributes="Bold"/>       
                                </StackLayout>     
                        </ViewCell>
                        <ViewCell Tapped="FBRedirect" >
                            <StackLayout Orientation="Horizontal" Margin="10">
                                <Image Source="facebook.png"  Margin="10,10" WidthRequest="23" />
                                <Label Text="Facebook"
                                    VerticalOptions="Center"
                                    Margin="15,0"
                                    VerticalTextAlignment="Center"
                                    Padding="2"
                                    x:Name="label7"/>       
                            </StackLayout>       
                        </ViewCell>
                        <ViewCell Tapped="IGRedirect">
                            <StackLayout Orientation="Horizontal" Margin="10">
                                <Image Source="instagram.png"  Margin="10,10" WidthRequest="23"/>
                                <Label Text="Instagram"
                                    VerticalOptions="Center"
                                    Margin="15,0"
                                    VerticalTextAlignment="Center"
                                    Padding="2"
x:Name="label8"/>       
                            </StackLayout>       
                        </ViewCell>   
                      </TableSection>
                   </TableRoot>
                </TableView>
        </StackLayout>
        </AbsoluteLayout>

解决方法

我最终删除了 StackLayout 并将布局标志和边界添加到 TableView

<ContentPage xmlns="http://xamarin.com/schemas/2014/forms"
             xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml" 
             x:Class="Example123.MoreContentPage"
             xmlns:local="clr-namespace:Example123.MarkupExtensions"
             Title="More Settings">
    <ContentPage.Content>
        <AbsoluteLayout>
                <TableView x:Name="MoreTable"
                           HasUnevenRows="True"
                            AbsoluteLayout.LayoutBounds="0,1,1"  AbsoluteLayout.LayoutFlags="All">
                    <TableRoot>  
                       <TableSection>
                        <ViewCell>
                            <StackLayout Orientation="Horizontal"
                                        BackgroundColor="#f7f7fb">
                                <Label Text="Preferences"
                                    VerticalOptions="Center"
                                    Margin="15,5,5"
                                    FontSize="17"
                                    Padding="10"
                                    TextColor="#000"
                                    FontAttributes="Bold"/>       
                            </StackLayout>     
                        </ViewCell>
                        <ViewCell Tapped="OpenFontSizing">
                                <StackLayout Orientation="Horizontal" Margin="10">
                                    <Image Source="settings.png"
                                        Margin="10,10,10"
                                        WidthRequest="23"/>
                                    <Label Text="App Settings - Adjust text Size"
                                        VerticalTextAlignment="Center"
                                        Margin="15,5"
                                        Padding="2"
                                        x:Name="label1"/>       
                                </StackLayout>
                         </ViewCell>
                        <ViewCell>
                            <StackLayout Orientation="Horizontal">
                                    <Label Text="Terms of Use"
                                        VerticalOptions="Center"
                                        Margin="15,5"
                                        FontSize="17"
                                        Padding="10"
                                        TextColor="#000"
                                        FontAttributes="Bold"/>
                                </StackLayout>     
                        </ViewCell>
                        <ViewCell Tapped="OpenTermsandConditions">
                            <StackLayout Orientation="Horizontal" Margin="10">
                                <Image Source="accept.png" WidthRequest="23"  Margin="10,10"/>
                                <Label Text="Terms of Use"
                                        Margin="15,5"
                                    Padding="2"
                                    VerticalTextAlignment="Center"
                                    FontSize="{Binding H2Font}"
                                    TextColor="#5e5e5e"/>       
                            </StackLayout>       
                        </ViewCell>
                        <ViewCell Tapped="DownloadRedirect">
                            <StackLayout Orientation="Horizontal" Margin="10">
                                <Image Source="download.png" Margin="10,10" WidthRequest="23"/>
                                <Label Text="Download our App!"
                                    VerticalOptions="CenterAndExpand"
                                    Margin="15,5"
                                    Padding="2"
                                    VerticalTextAlignment="Center"
                                    LineBreakMode="WordWrap"
                                    x:Name="label2"/>       
                            </StackLayout>       
                        </ViewCell>
                        <ViewCell>
                            <StackLayout Orientation="Horizontal">
                                    <Label Text="Contact Specialty"
                                        VerticalOptions="Center"
                                        Margin="15,5"
                                        Padding="10"
                                        FontSize="17"
                                        TextColor="#000"
                                        FontAttributes="Bold"/>       
                                </StackLayout>     
                        </ViewCell>
                            <ViewCell Tapped="SendEmail">
                                <StackLayout Orientation="Horizontal" Margin="10">
                                    <Image Source="envelope.png"  Margin="10,10" WidthRequest="23"/>
                                    <Label Text="Feedback or Questions"
                                        VerticalOptions="Center"
                                        Margin="15,5"
                                        VerticalTextAlignment="Center"
                                        Padding="2"
                                        x:Name="label3"/>       
                                </StackLayout>       
                            </ViewCell>
                        <ViewCell>
                            <StackLayout Orientation="Horizontal">
                                    <Label Text="News"
                                        VerticalOptions="Center"
                                        Margin="15,5"
                                        Padding="10"
                                        FontSize="17"
                                        TextColor="#000"
                                        FontAttributes="Bold"/>       
                                </StackLayout>     
                        </ViewCell>
                        <ViewCell Tapped="TWRedirect">
                            <StackLayout Orientation="Horizontal" Margin="10">
                                <Image Source="twitterFinal.png"  Margin="10,10"
                                    WidthRequest="23" />
                                <Label Text="Product News"
                                    VerticalOptions="Center"
                                    Margin="15,5"
                                    VerticalTextAlignment="Center"
                                    Padding="2"
                                   x:Name="label4"/>       
                            </StackLayout>       
                        </ViewCell>
                        <ViewCell>
                            <StackLayout Orientation="Horizontal">
                                    <Label Text="Share Market®"
                                        VerticalOptions="Center"
                                        Margin="15,5"
                                        FontSize="17"
                                        Padding="10"
                                        TextColor="#000"
                                        FontAttributes="Bold"/>       
                                </StackLayout>     
                        </ViewCell>
                   
                        <ViewCell Tapped="SeasonalRedirect">
                            <StackLayout Orientation="Horizontal" Margin="10">
                                <Image Source="search_share.png"  Margin="10,10"
                                    WidthRequest="23"  />
                                <Label Text="In Season Now! List"
                                    VerticalOptions="Center"
                                    Margin="15,5"
                                    VerticalTextAlignment="Center"
                                    Padding="2"
                                    x:Name="label5"/>       
                            </StackLayout>       
                        </ViewCell>
                        <ViewCell Tapped="SMRedirect">
                                <StackLayout Orientation="Horizontal" Margin="10">
                                    <Image Source="add.png"  Margin="10,10" WidthRequest="23"  />
                                    <Label Text="Sign up for Share Market® HIghlights Newsletter"
                                        VerticalOptions="Center"
                                        Margin="15,5"
                                        VerticalTextAlignment="Center"
                                        Padding="2"
                                        x:Name="label6"/>       
                                </StackLayout>       
                        </ViewCell>
                        <ViewCell>
                            <StackLayout Orientation="Horizontal">
                                    <Label Text="Social Networks"
                                        VerticalOptions="Center"
                                        Margin="15,5"
                                        Padding="10"
                                        FontSize="17"
                                        TextColor="#000"
                                        FontAttributes="Bold"/>       
                                </StackLayout>     
                        </ViewCell>
                        <ViewCell Tapped="FBRedirect" >
                            <StackLayout Orientation="Horizontal" Margin="10">
                                <Image Source="facebook.png"  Margin="10,10" WidthRequest="23" />
                                <Label Text="Facebook"
                                    VerticalOptions="Center"
                                    Margin="15,0"
                                    VerticalTextAlignment="Center"
                                    Padding="2"
                                    x:Name="label7"/>       
                            </StackLayout>       
                        </ViewCell>
                        <ViewCell Tapped="IGRedirect">
                            <StackLayout Orientation="Horizontal" Margin="10">
                                <Image Source="instagram.png"  Margin="10,10" WidthRequest="23"/>
                                <Label Text="Instagram"
                                    VerticalOptions="Center"
                                    Margin="15,0"
                                    VerticalTextAlignment="Center"
                                    Padding="2"
x:Name="label8"/>       
                            </StackLayout>       
                        </ViewCell>   
                      </TableSection>
                   </TableRoot>
                </TableView>
        </AbsoluteLayout>