Skip to content

Commit 914e4bc

Browse files
authored
fix(ios): improve TabView handling around more navigation controller (#11225)
1 parent 4070d91 commit 914e4bc

1 file changed

Lines changed: 20 additions & 5 deletions

File tree

packages/core/ui/tab-view/index.ios.ts

Lines changed: 20 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,14 @@ class UITabBarControllerDelegateImpl extends NSObject implements UITabBarControl
134134

135135
const owner = this._owner?.deref();
136136
if (owner) {
137+
// iOS lazily initializes moreNavigationController (e.g. on first access of
138+
// topViewController, or on first tap of the More tab) and can clear the
139+
// delegate we set in setViewControllers. Re-assert it whenever any tab is
140+
// selected so moreNav push/pop callbacks for tabs >= 5 still reach us.
141+
const moreNav = tabBarController.moreNavigationController;
142+
if (moreNav && owner.moreNavigationControllerDelegate && moreNav.delegate !== owner.moreNavigationControllerDelegate) {
143+
moreNav.delegate = owner.moreNavigationControllerDelegate;
144+
}
137145
owner._onViewControllerShown(tabBarController, viewController);
138146
}
139147
}
@@ -175,6 +183,12 @@ class UINavigationControllerDelegateImpl extends NSObject implements UINavigatio
175183
const owner = this._owner?.deref();
176184
if (owner) {
177185
owner._onViewControllerShown(navigationController.tabBarController, viewController);
186+
187+
// The cascade above may have just attached a queued Page to a Frame whose
188+
// Frame.onLoaded only fired post-animation. iOS won't re-layout on its own
189+
// after the push completes — trigger one so the late attachment becomes visible.
190+
viewController?.view?.setNeedsLayout();
191+
viewController?.view?.layoutIfNeeded();
178192
}
179193
}
180194
}
@@ -303,9 +317,8 @@ export class TabViewItem extends TabViewItemBase {
303317
export class TabView extends TabViewBase {
304318
public viewController: UITabBarControllerImpl;
305319
public items: TabViewItem[];
306-
320+
public moreNavigationControllerDelegate: UINavigationControllerDelegateImpl;
307321
private _delegate: UITabBarControllerDelegateImpl;
308-
private _moreNavigationControllerDelegate: UINavigationControllerDelegateImpl;
309322
private _iconsCache = {};
310323
private _bottomAccessoryNsView: View;
311324
private _ios: UITabBarControllerImpl;
@@ -327,12 +340,12 @@ export class TabView extends TabViewBase {
327340
initNativeView() {
328341
super.initNativeView();
329342
this._delegate = UITabBarControllerDelegateImpl.initWithOwner(new WeakRef(this));
330-
this._moreNavigationControllerDelegate = UINavigationControllerDelegateImpl.initWithOwner(new WeakRef(this));
343+
this.moreNavigationControllerDelegate = UINavigationControllerDelegateImpl.initWithOwner(new WeakRef(this));
331344
}
332345

333346
disposeNativeView() {
334347
this._delegate = null;
335-
this._moreNavigationControllerDelegate = null;
348+
this.moreNavigationControllerDelegate = null;
336349
this.viewController = null;
337350
this._ios = null;
338351
super.disposeNativeView();
@@ -590,7 +603,9 @@ export class TabView extends TabViewBase {
590603
}
591604

592605
// When we set this._ios.viewControllers, someone is clearing the moreNavigationController.delegate, so we have to reassign it each time here.
593-
this._ios.moreNavigationController.delegate = this._moreNavigationControllerDelegate;
606+
if (this._ios.moreNavigationController) {
607+
this._ios.moreNavigationController.delegate = this.moreNavigationControllerDelegate;
608+
}
594609
}
595610

596611
private _getIconRenderingMode(): UIImageRenderingMode {

0 commit comments

Comments
 (0)