iOS上不全局支持PushAsync,请使用NavigationPage [英] PushAsync is not supported globally on iOS, please use a NavigationPage

查看:64
本文介绍了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代码:

    <?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根页面(开始页)中,如下所示

 public App()
  {
      MainPage=new NavigationPage(new LoginPage());
  }

现在,我们可以在全局范围内使用PushAsyn()

Now, We can use PushAsyn() in Globally

这篇关于iOS上不全局支持PushAsync,请使用NavigationPage的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆