有点奇怪的。我在 Xamarin Forms (Shell) 中构建了一个应用程序,并且在 Android 上一切正常。当我导航到 ios(iphone 11 物理设备)中的新页面时,屏幕似乎弹出并调整大小。我认为这与视图中使用的安全区域属性有关,因为它似乎在安全区域中,然后调整大小以在安全区域中。
对安卓没有影响。
我无法在新项目中重新创建,但我当前的项目投入了大量时间,我不想重新开始......我无法重新适应我现有的项目,问题仍然存在。
下面是一些示例代码,但奇怪的是它似乎在一个新项目中工作,所以我正在寻找关于在某处可能设置什么来调试这个问题的指导。有什么想法吗?可以根据需要提供额外的代码示例,请告诉我。
我试过升级和降级软件包等没有效果。
套餐
我使用导航
private async Task ExecuteAddPageCommand()
{
await PushAsync(new AddPagePage());
}
PushAsync 在我的 baseviewmodel 中
public async Task<bool> PushAsync(Page page)
{
try
{
await Shell.Current.Navigation.PushAsync(page);
return true;
}
catch
{
await Shell.Current.GoToAsync(Utilities.Routes.ErrorModalPage);
return false;
}
}
并且页面具有标准属性(示例)
<?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:d="http://xamarin.com/schemas/2014/forms/design"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d"
xmlns:ios="clr-namespace:Xamarin.Forms.PlatformConfiguration.iOSSpecific;assembly=Xamarin.Forms.Core"
ios:Page.UseSafeArea="true"
Visual="Material"
x:Class="namespace:Thing.Views.AddPage"
xmlns:converter="clr-namespace:Thing.Converters"
xmlns:controls="clr-namespace:Thing.Controls"
xmlns:utilities="clr-namespace:Thing.Utilities"
>
<ContentPage.Resources>
<ResourceDictionary>
<converter:IntToEnumConverter x:Key="IntToEnum"/>
<converter:InverseBoolConverter x:Key="InverseBool"/>
</ResourceDictionary>
</ContentPage.Resources>
<ContentPage.Content>
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="2*"></RowDefinition>
<RowDefinition Height="5*"></RowDefinition>
<RowDefinition Height="1*"></RowDefinition>
</Grid.RowDefinitions>
<controls:PageHeader Grid.Row="0" ShowBackButton="true"
HeaderTitle="New Thing"
HeaderImage="{x:Static utilities:Icons.AddMenuIcon}"
BackCommand="{Binding NavigateBackCommand}"/>
<StackLayout Grid.Row="1">
<Label Text="What do you want to call this?" Style="{StaticResource FormLabel}"/>
<Entry Text="{Binding Name.Value}" Placeholder="E.g. My shiny thing"/>
</StackLayout>
<StackLayout Grid.Row="2" Orientation="Horizontal">
<Button HorizontalOptions="FillAndExpand" Text="Cancel" Command="{Binding NavigateBackCommand}"></Button>
<Button HorizontalOptions="FillAndExpand" Text="Save" Command="{Binding SaveCommand}"></Button>
</StackLayout>
</Grid>
</ContentPage.Content>
</ContentPage>