简体   繁体   English

如果从过流上下文视图控制器呈现错误呈现视图控制器

[英]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.

相关问题 在当前上下文情节提要板上呈现视图控制器 - Presenting view controller over current context storyboard 呈现视图控制器之上的模态视图控制器 - Modal view controller over Presenting view controller 使用CAShapeLayer遮罩呈现的视图控制器,也遮罩呈现的视图控制器 - masking presented view controller with CAShapeLayer also mask the presenting view controller 如何暂时隐藏同时呈现视图控制器的呈现视图控制器 - How to temporarily hide a presented View controller that is also presenting a view controller 呈现视图 controller 也可以是呈现视图 controller 吗? - Can a presented view controller also be a presenting view controller? 如何在呈现的View Controller和呈现的View Controller之间建立关系? - How to setup a relationship between the presenting View Controller and the presented View Controller? 呈现视图 controller 位于呈现视图 controller 下方 - Presented view controller place under presenting view controller 从选项卡控制器在当前上下文中显示模型视图控制器后出现黑屏 - Black screen after presenting model view controller in current context from tab controller iOS-从显示的视图控制器中呈现视图控制器会更改其高度 - iOS - Presenting a view controller from a presented view controller changes its height 从呈现视图控制器推送视图控制器 - Push View Controller from Presenting View Controller
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM