Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

iOS: Crash when opening a TabGroup inside a NavigationWindow #14021

Open
1 task done
m1ga opened this issue Apr 18, 2024 · 0 comments
Open
1 task done

iOS: Crash when opening a TabGroup inside a NavigationWindow #14021

m1ga opened this issue Apr 18, 2024 · 0 comments
Labels
bug ios needs triage This issue hasn't been reviewed by maintainers

Comments

@m1ga
Copy link
Contributor

m1ga commented Apr 18, 2024

I have searched and made sure there are no existing issues for the issue I am filing

  • I have searched the existing issues

Description

When trying to open a TabGroup withing a NavigationWindow the app will crash with

 *** Terminating app due to uncaught exception 'UIViewControllerHierarchyInconsistency', reason: 'child view controller:<UITabBarController: 0x10f838400> should have parent view controller:<TiViewController: 0x10e739260> but requested parent is:<TiRootViewController: 0x11181bc00>

In this PR d334ac9
some code was removed in iphone/Classes/TiUITabGroupProxy.m to fix iOS animations issues. When adding that back it won't crash.

- (void)windowDidOpen
{
  // Set parent view controller for UITabBarController
  TiUITabGroup *tabGroup = (TiUITabGroup *)self.view;
  if (tabGroup) {
    UITabBarController *tabController = [tabGroup tabController];
    UIViewController *parentController = [self windowHoldingController];
    [parentController addChildViewController:tabController];
    [tabController didMoveToParentViewController:parentController];
  }
  [super windowDidOpen];
}

Expected Behavior

show the TabGroup inside the NavigationWindow

Actual behavior

Crash

Reproducible sample

      // Main window creation
      var mainWindow = Ti.UI.createWindow({
          backgroundColor: '#fff'
      });      // NavigationWindow creation
      var navWindow = Ti.UI.createNavigationWindow({
          window: mainWindow
      });      // Button creation
      var button = Ti.UI.createButton({
          title: 'Apri TabGroup'
      });      // Adding the button to the main window
      mainWindow.add(button);      // Windows creation for the tabs
      var yellowWindow = Ti.UI.createWindow({
          backgroundColor: 'yellow'
      });      var whiteWindow = Ti.UI.createWindow({
          backgroundColor: 'white'
      });      var redWindow = Ti.UI.createWindow({
          backgroundColor: 'red'
      });      // Tabs creation
      var tab1 = Ti.UI.createTab({
          title: 'Giallo',
          window: yellowWindow
      });      var tab2 = Ti.UI.createTab({
          title: 'Bianco',
          window: whiteWindow
      });      var tab3 = Ti.UI.createTab({
          title: 'Rosso',
          window: redWindow
      });      // TabGroup creation
      var tabGroup = Ti.UI.createTabGroup({
          tabs: [tab1, tab2, tab3]
      });      // Adding event to the button in order to open the TabGroup
      button.addEventListener('click', function() {
          // Open the TabGroup in NavigationWindow
          navWindow.openWindow(tabGroup);
      });      // Open the  NavigationWindow
      navWindow.open();

Steps to reproduce

Start the app and press the button

Platform

iOS

SDK version you are using

12.3.0

Alloy version you are using

No response

@m1ga m1ga added bug needs triage This issue hasn't been reviewed by maintainers ios labels Apr 18, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug ios needs triage This issue hasn't been reviewed by maintainers
Projects
None yet
Development

No branches or pull requests

1 participant