Uploaded image for project: 'Titanium SDK/CLI'
  1. Titanium SDK/CLI
  2. TIMOB-27865

iOS: Titanium should add view controllers as children

    Details

    • Type: Improvement
    • Status: Closed
    • Priority: High
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: Release 10.0.0
    • Component/s: iOS
    • Labels:
      None
    • Story Points:
      5
    • Sprint:
      2021 Sprint 1

      Description

      Copied from here -

      When adding windows to windows (e.g. using Titanium.UI.createNavigationWindow), Titanium ignores the rules of view controller containment on iOS and doesn't add view controllers as children.

      The code responsible for calling the required methods has been commented out with a TODO: Revisit for almost 5 years (as of writing this issue):

      titanium_mobile/iphone/TitaniumKit/TitaniumKit/Sources/API/TiWindowProxy.m

       - (void)attachViewToTopContainerController 
       { 
         UIViewController<TiControllerContainment> *topContainerController = [[[TiApp app] controller] topContainerController]; 
         UIView *rootView = [topContainerController hostingView]; 
         TiUIView *theView = [self view]; 
         [rootView addSubview:theView]; 
         [rootView bringSubviewToFront:theView]; 
        
         // TODO: Revisit 
         /* 
           UIViewController<TiControllerContainment>* topContainerController = [[[TiApp app] controller] topContainerController]; 
           UIView *rootView = [topContainerController hostingView]; 
        
           UIViewController* thisViewController = [self hostingController]; 
           UIView* theView = [thisViewController view]; 
           [theView setFrame:[rootView bounds]]; 
        
           [thisViewController willMoveToParentViewController:topContainerController]; 
           [topContainerController addChildViewController:thisViewController]; 
        
           [rootView addSubview:theView]; 
           [rootView bringSubviewToFront:theView]; 
           [thisViewController didMoveToParentViewController:topContainerController]; 
            */ 
       }
      

      This causes issues in view-controller-backed modules (such as PSPDFKit), especially during view controller presentation. UIKit eve logs a warning message about this:

      "Presenting view controllers on detached view controllers is discouraged."

      Steps to reproduce-

      Create a plain window and a navigation window. Run the app and inspect the view hierarchy.

      var window = Titanium.UI.createWindow({
          backgroundColor: "white",
      })
       
      var navigationWindow = Titanium.UI.createNavigationWindow({
          window: window,
      })
       
      navigationWindow.open()
      
      

      Expected behavior -

      Every view controller in the hierarchy (except for TiRootViewController) has a correctly set parent view controller.

      Actual behavior -

      UINavigationController managed by Titanium.UI.NavigationWindow is detached and has no parent view controller. See attached image view "controller.png"

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                vijaysingh Vijay Singh
                Reporter:
                vijaysingh Vijay Singh
                Reviewer:
                Jan Vennemann
                Tester:
                Satyam Sekhri
              • Watchers:
                9 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved:

                  Backbone Issue Sync

                  • Backbone Issue Sync is enabled for your project, but we do not have any synchronization info for this issue.

                    Git Integration