9 Replies
      Latest reply on Mar 23, 2020 12:20 PM by CAVUCO
      dknudsen Level 1 Level 1 (0 points)

        Hello,

         

        Switching from iOS 12 to 13 caused that our views no longer function correctly. This is due that when NavigationController.PushViewController is called, it no longer calls ViewWill/DidAppear and their opposite Will/DidDisappear. I have read the iOS 13 release notes and saw the video and everyhing that has been mentioned regarding these events is directed at presentation of card-like modal views, which has nothing to do with the PushViewController function. In iOS 12 the PushViewController would navigate to a new ViewController and therefrom I could click on the default back button to navigate back to the previous one and it called the relevant lifecycle events. That is no longer possible with iOS 13.

         

        The way our Views are constructed are quite old fashioned. We use XIB files to construct our Views and furthermore, this is done programmatically and the language used is Objective-C.

         

        Most of our views are based on UIViewControllers, UITables and UITableViewController.

         

        Now one thing I do know is that UITableViewController, through the use of ViewDidAppear/will, will call ReloadData to correctly set up the table, but since using PushViewController no longer calls these events, the layout will be broken.

         

        It could possibly something that we missed or havent understood about the framework, but I have written this after searching through countless websites about someone with a similar issue, but to no avail.

         

        An example of what happens can be seen below:

         

         

        What I expect it to call is

         

        ViewDidLoad --> ViewWillAppear --> ViewDidAppear

         

        and when leaving the View it will call these:

         

        ViewWillDisappear --> ViewDidDisappear --> ViewDidUnload(deprecated)

         

         

        And no other viewController lifecycles except for ViewDidLoad is called.

        This causes my view to look completely wrong.

         

         

        For some reason the two images i pasted in here arent visible.

        • Re: Navigation Controller PushViewController no longer calls ViewDidAppear/will
          Claude31 Level 8 Level 8 (8,465 points)

          A possible reason is the default display mode a a view. It used to be fullscreen, it is now "automatic", which is why you see a small fraction of the calling veiw at top ; view does not disappear ; when you return, view has not to aappear.

           

          Try to change (in viewDidLoad):

          self.modalPresentationStyle = .fullScreen          // where self is the VC of course

           

          Or do it in IB.

          • Re: Navigation Controller PushViewController no longer calls ViewDidAppear/will
            CAVUCO Level 1 Level 1 (0 points)

            Hi,  I am having exactly the same issue as you were using  IOS 13.3 and Xcode 11.3.  I'm using code to create navigationcontroller and XIB.

            I am using pushViewController

             

            I entered

             

            <self.modalPresentationStyle=UIModalPresentationFullScreen;>

             

            within each VC viewDidLoad

             

            The ViewWillAppear still does not call when I popRootViewController or pop back to a previous VC.

             

            I am creating the naviagtioncontroller as the rootcontroller within AppDelegate.

             

            Can you provide me what you did to resolve this?

              • Re: Navigation Controller PushViewController no longer calls ViewDidAppear/will
                Claude31 Level 8 Level 8 (8,465 points)

                The problem is explained in viewWillAppear doc:

                This method is called before the view controller'€™s view is about to be added to a view hierarchy and before any animations are configured for showing the view.

                 

                As the view is aalready in view hiearchy, it is not called.

                 

                I would try a few approaches (did not fully test):

                - move the code you need from viewWillAppear to viewDidDisappear of the controller you leave (if possible)

                - send a notification from the view you leave (in viewWillDisparrear) to the view that will appear and move the code in the action for this notification

                - Try to set fullscreen in IB and not in code (worked for me)

                  • Re: Navigation Controller PushViewController no longer calls ViewDidAppear/will
                    CAVUCO Level 1 Level 1 (0 points)

                    The navController was not created in IB.

                    I used <self.modalPresentationStyle=UIModalPresentationFullScreen;> within every VC wiewDidLoad as stated above.

                     

                    I had someone send me a test project with three pushed VCs and when he used popPopViewController:animated to return to previous VC it calls viewWillAppear on that VC.  This is how my app worked before IOS 13 update. BTW, he used storyboard and the NavController was in the IB and ptresentation was set to automatic, which is even more confusing.

                     

                    If I launch an actual device instead of the simulator (and that device has IOS 13.3.1), it works perfectly and just as the simulators under previous versions worked.  So I'm really at a loss.  Not sure how dknudsen above found this as a solutiuon because he sounds exactly like me.

                     

                    I am implementing an AppDelegate for the views.  I made that NavController fullscreen and the views related to that fullscreen with the AppDelegate but not sure if the order has something to do with it.

                     

                    Do you have an example of that notification method you suggested.  HAve never used notification