viewDidAppear and viewDidDisappear not called when modalPresentationStyle=UIModalPresentationCustom

≯℡__Kan透↙ 提交于 2019-12-08 12:59:34

问题


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?


回答1:


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.



来源:https://stackoverflow.com/questions/34517361/viewdidappear-and-viewdiddisappear-not-called-when-modalpresentationstyle-uimoda

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!