当 modalPresentationStyle=UIModalPresentationCustom 时不调用 viewDidAppear 和 viewDidDisappear [英] viewDidAppear and viewDidDisappear not called when modalPresentationStyle=UIModalPresentationCustom

查看:64
本文介绍了当 modalPresentationStyle=UIModalPresentationCustom 时不调用 viewDidAppear 和 viewDidDisappear的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要做一个自定义的演示动画,当我设置这些 setTransitioningDelegate 和 modalPresentationStyle=UIModalPresentationCustom

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

动画是完美的,除非在呈现的视图控制器中没有调用 viewDidAppear 和 viewDidDisappear.这与 https://developer.apple.com/library/ios/samplecode/LookInside/Introduction/Intro.html

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];

为什么在没有给出modalPresentationStyle时调用方法?

Why the methods are called when no modalPresentationStyle is given?

推荐答案

这是正确的行为,因为呈现新的视图控制器只会隐藏呈现的视图控制器.当呈现的视图控制器被关闭时,它不会将视图添加到层​​次结构中,并且当呈现的视图控制器被呈现时,它不会从层次结构中删除呈现的视图控制器视图.

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.

这篇关于当 modalPresentationStyle=UIModalPresentationCustom 时不调用 viewDidAppear 和 viewDidDisappear的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆