OnBackPressed Xamarin PCL 我在哪里重写方法

OnBackPressed Xamarin PCL where do i override the method

我正在尝试覆盖 pcl 项目中的 OnBackPressed() 方法。我不知道我必须在哪里查看它。在便携式项目中还是在 android 中?我想在单击后退按钮时导航到另一个页面。有什么建议么?

您需要在自定义页面 类 的 PCL 项目中覆盖 OnBackButtonPressed。

protected override bool OnBackButtonPressed()
{
    // call your custom navigation code here

    // returning true because you are handling the navigation
    return true;
}

请注意,此事件在按下硬件后退按钮时引发,但不会在 iOS 上引发。