【问题标题】:viewDidAppear and viewDidDisappear not called when modalPresentationStyle=UIModalPresentationCustommodalPresentationStyle=UIModalPresentationCustom 时未调用 viewDidAppear 和 viewDidDisappear
【发布时间】:2015-12-29 19:03:08
【问题描述】:

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

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

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

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

【问题讨论】:

    标签: ios uiviewcontroller presentviewcontroller uimodalpresentationstyle


    【解决方案1】:

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

    短篇小说;它隐藏呈现视图控制器的视图而不是删除它。因此不会调用这些方法。

    【讨论】:

    • got.it.so 我在视图生命周期方法中有一些逻辑。所以唯一的方法是移动它们?以及为什么在没有给出 modalPresentationStyle 时调用这些方法?
    • 难道你不能创建一个委托并根据你的逻辑从呈现的视图控制器在适当的时间调用委托方法吗?
    • 这是另一个与您的问题类似的问题:stackoverflow.com/questions/9621346/…
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-03-26
    • 2012-08-26
    • 1970-01-01
    • 1970-01-01
    • 2012-10-31
    • 2011-07-01
    相关资源
    最近更新 更多