8 Replies
      Latest reply on Oct 31, 2019 8:01 AM by Simone Pasetto
      Simone Pasetto Level 1 Level 1 (0 points)

        hi, with ios13 when i call dismiss of modalview not call viewWillAppear on bottom view, why? with ios12 works

        • Re: viewWillAppear and modalview
          DelawareMathGuy Level 3 Level 3 (210 points)

          modal presentations have changed in iOS 13, and yes indeed, viewWillAppear is not called when (most?) modals are dismissed.

           

          take a look at the WWDC 19 video "Modernizing Your UI for iOS 13," and you'll see the changes.  i think there are new callbacks added to iOS13, and i think these are mentioned in the video, but i thought they weren't yet available in the beta releases (i haven't checked recently).

           

          one thing i've started to do is to clean up some existing code to handle this, often by setting a completion handler to be called when the modal viewController is dismissed (example: call a completion handler that does something like "self.tableView.reloadData()" for the presenting viewController after the presented viewController is dismissed).

           

          you can handle more sophisticated cases either by adding some level of delegation to your modal view controller, or implementing a callback function that the modal viewController can execute for you before being dismissed.

           

          hope that helps,

          DMG

            • Re: viewWillAppear and modalview
              Simone Pasetto Level 1 Level 1 (0 points)

              thanks i will try... i have over 300 xib views... do you know if any new betas will published? i found also a bug in settings bundle that not can edit field

                • Re: viewWillAppear and modalview
                  DelawareMathGuy Level 3 Level 3 (210 points)

                  Simone,

                   

                  sorry that i can't help anymore on what i said above -- and i'm not sure i'm even covering all cases in my suggestions.  i certainly don't know about beta releases, although they tend to come about every two weeks (the last XCode beta 3 release was July 2, so one would expect another tomorrow, July 16).

                   

                  i went back to the WWDC video, and the best i can summarize is that

                   

                  (1)  most modal presentations in your app will default to a sheet presentation in iOS 13.

                   

                  (2)  it appears you can defeat this by seting the modalPresentationStyle to .fullScreen [either in code, whether you call present() or when you see the about-to-be-presented controller in prepareForSegue(), or in a storyboard by checking the modal presentation style of a segue] -- but you probably should not do this unless there's a UI reason to do it (and not just a coding reason to avoid having to deal with a sheet presentation)

                   

                  (3)  the viewWillAppear ... viewWillDisappear calls you are used to handle modal transitions definitely are not the places to react to modal presentations that default to sheets, since the presenting view controller is not removed from the view hierarchy.

                   

                  (4)  all of this transition detail is now handled by adopting the UIAdaptivePresentationControllerDelegate protocol.  that's where you'll find the new callbacks mentioned in the WWDC video.

                   

                  from there, you are on your own.  i have not taken any action on implementing any of this myself, and i'd prefer to wait a little longer to do so.

                   

                  hope that helps, and good luck,

                  DMG

              • Re: viewWillAppear and modalview
                hacknicity Level 3 Level 3 (130 points)

                DelawareMathGuy is correct. The the new delegate methods for detecting when an interactive dismissal has occurred do work as documented. I've written a pretty comprehensive Medium article on the changes: https://medium.com/@hacknicity/view-controller-presentation-changes-in-ios-13-ac8c901ebc4e

                • Re: viewWillAppear and modalview
                  shulumba Level 1 Level 1 (0 points)

                  Hi Simone! I found this bug too.
                  Try this one
                  self.navigationController.modalPresentationStyle = UIModalPresentationFullScreen;
                  It helps me. Thanks!

                    • Re: viewWillAppear and modalview
                      Simone Pasetto Level 1 Level 1 (0 points)

                         NView.modalPresentationStyle=UIModalPresentationOverFullScreen;

                                  [self presentViewController:NView animated:NO

                                                   completion:nil];

                       

                      i solve it with this:

                       

                                
                         NView.modalPresentationStyle=UIModalPresentationOverFullScreen;
                         [self presentViewController:NView animated:NO
                                                   completion:nil];
                      
                       NView.didDismiss = ^(NSString *data) 
                            {
                                 if([[[UIDevice currentDevice] systemVersion] floatValue] >= 8.0f)
                                    {
                                    [self viewWillAppear];  
                                    }
                                  };
                      
                      and inside NView when i dismiss i call didDismiss()