最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

Handling iOS Back button in Prism (MAUI) - Stack Overflow

programmeradmin3浏览0评论

We have a Prism MAUI app that is deployed to Android and iOS. In some of the ViewModels I would like to be able to catch back navigation using the Prism interface IConfirmNavigationAsync.

This works perfectly in Android but in iOS it never gets called.

When the Back button is pressed in iOS I see this message in the debug output

NavigationPage has encountered an unhandled GoBack. Be sure to inherit from PrismNavigationPage.

That is thrown by the NavigationPageSystemGoBackBehavior when the PageNavigationService.NavigationSource == Device. This makes me think that I should be handling that Back button myself or offering up a Prism one but I don't know how to do that.

FWIW the following fire just fine

  • OnNavigatedFrom
  • IDestructible.Destroy
  • OnDisappearing

We initialise Prism like this:

static void BuildPrism(PrismAppBuilder prism)
{
    Type viewModelToShow = null;

    viewModelToShow = typeof(HomeViewModel);

    prism.CreateWindow(
                string.Format("NavigationPage/{0}", viewModelToShow.Name),
                HandleNavigationError);
}
发布评论

评论列表(0)

  1. 暂无评论