diff --git a/tns-core-modules/ui/page/page.ios.ts b/tns-core-modules/ui/page/page.ios.ts index c7c2127bf..b22858e9f 100644 --- a/tns-core-modules/ui/page/page.ios.ts +++ b/tns-core-modules/ui/page/page.ios.ts @@ -190,8 +190,13 @@ class UIViewControllerImpl extends UIViewController { } const frame = owner.frame; - // Skip navigation events if we are hiding because we are about to show modal page. + // Skip navigation events if we are hiding because we are about to show modal page + // or because we are in tab and another controller is selected. + const tab = this.tabBarController; if (!owner._presentedViewController && frame && frame.currentPage === owner) { + const willSelectViewController = tab && (tab)._willSelectViewController; + if (!willSelectViewController + || willSelectViewController === tab.selectedViewController) { let isBack = isBackNavigationFrom(this, owner); owner.onNavigatingFrom(isBack); } @@ -225,8 +230,16 @@ class UIViewControllerImpl extends UIViewController { const frame = page.frame; // We are not modal page, have frame with backstack and navigation queue is empty and currentPage is closed // then pop our backstack. + // If we are in frame wich is in tab and tab.selectedControler is not the frame + // skip navigation. + const tab = this.tabBarController; + const fireNavigationEvents = !tab + || tab.selectedViewController === this.navigationController; + if (!modalParent && frame && frame.backStack.length > 0 && frame.navigationQueueIsEmpty() && frame.currentPage === page) { - (frame)._backStack.pop(); + if (fireNavigationEvents) { + (frame)._backStack.pop(); + } } page._enableLoadedEvents = true; @@ -247,7 +260,7 @@ class UIViewControllerImpl extends UIViewController { page._enableLoadedEvents = false; - if (!modalParent) { + if (!modalParent && fireNavigationEvents) { // Last raise onNavigatedFrom event if we are not modally shown. page.onNavigatedFrom(isBack); } @@ -425,7 +438,7 @@ export class Page extends PageBase { if (child === this.actionBar) { return true; } - + // Don't add modal pages our visual tree. if (child !== this.content) { return true; diff --git a/tns-core-modules/ui/tab-view/tab-view.ios.ts b/tns-core-modules/ui/tab-view/tab-view.ios.ts index fb16fe5bc..94808921b 100644 --- a/tns-core-modules/ui/tab-view/tab-view.ios.ts +++ b/tns-core-modules/ui/tab-view/tab-view.ios.ts @@ -59,6 +59,8 @@ class UITabBarControllerDelegateImpl extends NSObject implements UITabBarControl owner._handleTwoNavigationBars(backToMoreWillBeVisible); } + (tabBarController)._willSelectViewController = viewController; + return true; } @@ -71,6 +73,8 @@ class UITabBarControllerDelegateImpl extends NSObject implements UITabBarControl if (owner) { owner._onViewControllerShown(viewController); } + + (tabBarController)._willSelectViewController = undefined; } }