diff --git a/packages/core/ui/frame/index.ios.ts b/packages/core/ui/frame/index.ios.ts
index 5dca6e46ca..ae20d2afff 100644
--- a/packages/core/ui/frame/index.ios.ts
+++ b/packages/core/ui/frame/index.ios.ts
@@ -14,6 +14,7 @@ import { Trace } from '../../trace';
import { SlideTransition } from '../transition/slide-transition';
import { FadeTransition } from '../transition/fade-transition';
import { SharedTransition } from '../transition/shared-transition';
+import type { Transition } from '../transition';
export * from './frame-common';
@@ -73,7 +74,11 @@ export class Frame extends FrameBase {
}
this._removeFromFrameStack();
- this.viewController = null;
+
+ if (this.viewController) {
+ this.viewController.lastExecutingTransition = null;
+ this.viewController = null;
+ }
// This was the last frame so we can get rid of the controller delegate reference
if (this._isFrameStackEmpty()) {
@@ -475,6 +480,9 @@ class UINavigationControllerDelegateImpl extends NSObject implements UINavigatio
}
}
+ // Keep a strong reference of the last executing transition to prevent gc from collecting it
+ navigationController.lastExecutingTransition = transition;
+
if (transition?.iosNavigatedController) {
return transition.iosNavigatedController(navigationController, operation, fromVC, toVC);
}
@@ -509,6 +517,7 @@ class UINavigationControllerDelegateImpl extends NSObject implements UINavigatio
@NativeClass
class UINavigationControllerImpl extends UINavigationController {
private _owner: WeakRef;
+ public lastExecutingTransition: Transition;
public static initWithOwner(owner: WeakRef): UINavigationControllerImpl {
const navigationBarClass = owner.deref()?.iosNavigationBarClass ?? null;