Skip to content

Conversation

@CatchABus
Copy link
Contributor

@CatchABus CatchABus commented Nov 6, 2025

PR Checklist

What is the current behavior?

Right now, if one removes a view like Frame from the view-tree and decides to re-add it there, the view controller will have already been disposed and there's no handling for creating it anew.

What is the new behavior?

Create view controller during createNativeView step if missing.
We keep the view controller initialization inside constructors because it's needed for special cases and tests.
Also, there are a couple of small improvements that help TabView tab transition animation work even if view was disposed in the meantime and let tests pass.

This might also be a solution to the problem described in #10940

@nx-cloud
Copy link

nx-cloud bot commented Nov 6, 2025

View your CI Pipeline Execution ↗ for commit 5ed501c

Command Status Duration Result
nx test apps-automated -c=ios ✅ Succeeded 2s View ↗
nx run-many --target=test --configuration=ci --... ✅ Succeeded 1s View ↗

☁️ Nx Cloud last updated this comment at 2025-11-07 00:04:52 UTC

@CatchABus CatchABus marked this pull request as draft November 6, 2025 11:17
@NathanWalker NathanWalker requested a review from Copilot November 6, 2025 17:34
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR enhances view controller lifecycle management on iOS by adding defensive null checks and supporting view controller recreation scenarios. The changes ensure that view controllers can be safely recreated after disposal, preventing potential crashes when native views are accessed after disposal.

Key changes:

  • Added createNativeView methods that recreate view controllers if they've been disposed
  • Added null safety checks throughout view controller access points
  • Changed _ios properties from public to private across Frame, Page, and TabView components

Reviewed Changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.

File Description
packages/core/ui/tab-view/index.ios.ts Adds view controller recreation in createNativeView, adds null checks for _ios property access, updates method signatures to accept tab bar controller parameter for safer navigation
packages/core/ui/page/index.ios.ts Adds view controller recreation in createNativeView and null check for viewController property
packages/core/ui/frame/index.ios.ts Changes _ios to private, adds view controller recreation in createNativeView, removes obsolete tslint comments

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

CatchABus and others added 2 commits November 7, 2025 00:20
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
@CatchABus CatchABus marked this pull request as ready for review November 6, 2025 22:32
@NathanWalker NathanWalker merged commit 8fea9e5 into NativeScript:main Nov 7, 2025
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants