[英]Wrong presenting view controller if presented from an over-current-context view controller
So I'm having an issue with 3 view controllers I have. 所以我遇到了3个视图控制器的问题。 I have View Controller A which presents a View Controller B with a presentation style of currentContext
. 我有View Controller A,它提供了一个视图控制器B,其显示风格为currentContext
。 This View Controller B presents a View Controller C with the default presentation style. 此视图控制器B呈现具有默认演示样式的视图控制器C. Something like this: presents over current context presents regularly VC A -------------------------------> VC B --------------------> VC C
这样的事情: presents over current context presents regularly VC A -------------------------------> VC B --------------------> VC C
The problem is, when I want to dismiss the View Controller C, the presentingViewController
property points to VC A instead of VC B, and also, the viewWillAppear
of VC B is not called, while the viewWillAppear
in VC A is. 问题是,当我想要关闭View Controller C时, presentingViewController
属性指向VC A而不是VC B,而VC A的viewWillAppear
也没有被调用,而VC A中的viewWillAppear
是。
I cannot use the completion block of dismiss(animated flag: Bool, completion: (() -> Void)? = nil)
because VC B doesn't have control over the dismissal of VC C. It is a flow that can be started from several points in the app, so the management of the navigation of this flow is done in a separate class. 我不能使用dismiss(animated flag: Bool, completion: (() -> Void)? = nil)
的完成块dismiss(animated flag: Bool, completion: (() -> Void)? = nil)
因为VC B无法控制VC C的解雇。这是一个可以启动的流程从应用程序的几个点,所以这个流程的导航管理是在一个单独的类中完成的。
What is happening here? 这里发生了什么? I really need the viewWillAppear
of VC B to be called. 我真的需要调用VC B的viewWillAppear
。
@Kinopio - I guess the problem you are facing is because you are dismissing the controller from VC A, so here self point to current class. @Kinopio - 我猜你遇到的问题是因为你从VC A中解雇控制器,所以这里自我指向当前的类。 You need to pass the message to VC B and that dismiss from there. 您需要将消息传递给VC B并从那里解除。
Like 喜欢
//code in VC A
func dismissViewControllerNoC(){
viewControllerNoB.dismiss()
}
//code in VC B
func dismiss(){
dismiss(animated flag: Bool,
completion: (() -> Void)? = nil)
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.