简体   繁体   English

在关闭当前ViewController之后快速显示,然后Presenting ViewController不调用viewWillAppear()

[英]Swift after dismiss Current ViewController then the Presenting ViewController not calling viewWillAppear()

In my case, I am using two view controller VC1 and VC2 . 就我而言,我正在使用两个视图控制器VC1VC2 Here, VC1 button click to Present Modally and Over Full Screen presentation with Cross Dissolve Transition to presenting VC2. 在这里,VC1按钮单击以通过Cross Dissolve过渡到模式VC2来呈现Present ModallyOver Full Screen演示。 Now, from VC2 dismiss then I didn't get call VC1 viewWillAppear() . 现在,从VC2关闭,然后我没有接到VC1 viewWillAppear()

I am not using code base for Present model. 我没有为Present模型使用代码库。 I am using Storyboard Segue . 我正在使用Storyboard Segue

Why it happening and how to fix this? 为什么会发生以及如何解决此问题?

在此处输入图片说明

From Docs , 文档中

Note 注意

If a view controller is presented by a view controller inside of a popover, this method is not invoked on the presenting view controller after the presented controller is dismissed. 如果视图控制器是由弹出框内的视图控制器提供的,则在关闭所提供的控制器后,不会在呈现的视图控制器上调用此方法。

So according to the documentation when a ViewController presents another ViewController modally this method will not be called. 因此,根据文档,当ViewController以模态形式提供另一个ViewController时,将不会调用此方法。 To fix this you need to use 要解决此问题,您需要使用

func dismiss(animated flag: Bool, 
  completion: (() -> Void)? = nil)

and move(or repeat) some of viewWillLoad logic to completion handler. 并将一些viewWillLoad逻辑移动(或重复)到完成处理程序。

Change presentation to Full screen or If you want to stick to Over Full Screen then make vc2 delegate of vc1 and call delegate method on dismiss. 将演示文稿更改为Full screen或者如果您要坚持Over Full Screen则使vc2成为vc1的委托,并在关闭时调用委托方法。

To understand the concept you can refer to : https://medium.com/livefront/why-isnt-viewwillappear-getting-called-d02417b00396 要了解该概念,您可以参考: https : //medium.com/livefront/why-isnt-viewwillappear-getting-called-d02417b00396

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Swift 在呈现新的 ViewController 后关闭当前的 ViewController - Swift dismiss current Viewcontroller after presenting new ViewController 有没有办法在呈现另一个ViewController之后将其关闭? - Is there a way to dismiss the current ViewController after presenting another? 在使用Swift展示新的Viewcontroller后如何关闭以前的Viewcontroller? - How to dismiss previous Viewcontroller after presenting new Viewcontroller using Swift? 如何在Swift中关闭当前的ViewController并更改为新的ViewController? - How to dismiss the current ViewController and change to the new ViewController in Swift? Swift - 再次呈现 ViewController 后,推动 ViewController 不起作用 - Swift - pushing ViewController not working after presenting ViewController again 使用NavigationViewController swift呈现ViewController - presenting ViewController with NavigationViewController swift iOS ViewController modalPresentationStyle、不透明背景和 viewWillAppear 来自呈现的 ViewController - iOS ViewController modalPresentationStyle, opaque background and viewWillAppear from presenting ViewController 如何在 Swift 中关闭 ViewController? - How to dismiss ViewController in Swift? 关闭viewController总是触发viewDidLoad,从不触发viewWillAppear - dismiss viewController always trigger viewDidLoad and never viewWillAppear 在 swift 中获取 viewController.view 的呈现视图控制器 - Get the presenting viewController of viewController.view in swift
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM