iosuiviewcontrollerpresentviewcontrolleruimodalpresentationstyle

viewDidAppear and viewDidDisappear not called when modalPresentationStyle=UIModalPresentationCustom


I need to do a custom presentation animation and when i set both these setTransitioningDelegate and modalPresentationStyle=UIModalPresentationCustom

The animation is perfect with unless the viewDidAppear and viewDidDisappear is not called in the presenting viewcontroller.This is same for Apple sample code in https://developer.apple.com/library/ios/samplecode/LookInside/Introduction/Intro.html

[overlay setTransitioningDelegate:[self transitioningDelegate]];  
overlay.modalPresentationStyle=UIModalPresentationCustom;  
[self presentViewController:overlay animated:YES completion:NULL];

Why the methods are called when no modalPresentationStyle is given?


Solution

  • This is the correct behaviour as presenting a new view controller only hides the presenting view controller. It doesn't add the view to the hierarchy when the presented view controller is dismissed, and it doesn't remove the presenting view controller view from the hierarchy when the view controller that is presented is presented.

    Short story; it hides the view of the presenting view controller instead of removing it. Therefore the methods aren't invoked.