iOS 不支持 PushAsync,请使用 NavigationPage [英] PushAsync is not supported globally on iOS, please use a NavigationPage
本文介绍了iOS 不支持 PushAsync,请使用 NavigationPage的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
当我处理 ListView
项目的 Tap 事件时,一切正常,但是当我在 TabbedPage
中使用它时,它显示异常,请提供解决方案提前感谢这个问题.
Everything is working fine when I am handling the Tap event of a ListView
item, but when I use this in a TabbedPage
it shows the exception please provide a solution to this problem thanks in advance.
异常:iOS 不支持 PushAsync,请使用 NavigationPage.
Exception: PushAsync is not supported globally on iOS, please use a NavigationPage.
这是 Xaml 代码:
Here is the Xaml Code:
<?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:local="clr-namespace:NavTest" x:Class="NavTest.NavTestPage" Title="Home">
<ContentPage.Content>
<StackLayout Orientation="Vertical" VerticalOptions="Center">
<Label Text="Welcome to Xamarin Forms!" VerticalOptions="Center" HorizontalOptions="Center" />
<!--<Button Text="Go to " BackgroundColor="Lime" VerticalOptions="Center" Clicked="Handle_Clicked" >
</Button>-->
<ListView x:Name="myListView" ItemSelected="Handle_ItemSelected">
<ListView.ItemTemplate>
<DataTemplate>
<ViewCell>
<Label Text="{Binding}" VerticalOptions="Center" HorizontalOptions="Center" />
</ViewCell>
</DataTemplate>
</ListView.ItemTemplate>
</ListView>
</StackLayout>
</ContentPage.Content>
</ContentPage>
这是 OnClick 处理程序:
Here's the OnClick Handler:
async void Handle_Clicked(object sender, System.EventArgs e)
{
await Navigation.PushAsync(new Page1());
}
推荐答案
此错误仅在 iOS 中运行时会出现.
This error will come while running in iOS only.
在 App.cs Rootpage(起始页)中给出如下
public App()
{
MainPage=new NavigationPage(new LoginPage());
}
现在,我们可以全局使用 PushAsyn()
Now, We can use PushAsyn() in Globally
这篇关于iOS 不支持 PushAsync,请使用 NavigationPage的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文