【问题标题】:Redirect To Home Screen on iOs return在 iOs 返回时重定向到主屏幕
【发布时间】:2019-05-07 07:53:14
【问题描述】:

目前,当我的 android 应用程序重新启动到前台时,它总是返回到主屏幕 (RootPage)。

代码如下

protected override void OnCreate(Bundle bundle)
{
    ...
    LoadApplication(new App());
    ...
}

App.xaml.cs

public App()
{
    ...
    MainPage =  NavigationPageHelper.Create(new RootPage());
    ...
}

有没有办法让 iO 具有相同的行为,这样当应用程序返回前台时,它总是会重定向到主屏幕。目前它停留在上次停留的屏幕上。

【问题讨论】:

    标签: xamarin xamarin.forms


    【解决方案1】:

    在表单的应用程序子类 (App) 中,您可以使用 OnResume 覆盖来处理该检查:

    类似:

    protected override void OnResume()
    {
        // Handle when your app resumes
        if (!(MainPage is RootPage)) // Assuming RootPage is what  NavigationPageHelper.Create assigns it in your App .ctor
        {
            MainPage = NavigationPageHelper.Create(new RootPage());
        }
    }
    

    【讨论】:

      猜你喜欢
      • 2017-05-16
      • 1970-01-01
      • 2015-12-11
      • 1970-01-01
      • 1970-01-01
      • 2022-07-01
      • 2021-04-09
      • 2019-05-24
      • 2020-09-22
      相关资源
      最近更新 更多