[英]Dismissal of modal view hierarchy — An elegant solution
I have a view hierarchy like this: 我有一个这样的视图层次结构:
Now on some activity I need to cancel the whole modal view hierarchy. 现在,在某些活动中,我需要取消整个模式视图层次。 So what I am doing is, I am sending a notification on that event from view controller 3 and listeneing to that notification in view controller and then executing:
所以我正在做的是,我正在从视图控制器3发送关于该事件的通知,并在视图控制器中侦听该通知,然后执行:
[[NSNotificationCenter defaultCenter] removeObserver:self name:@"cancelViews" object:nil];
This works but there is one problem. 这有效,但是有一个问题。 As per my app flow I am ending up registering for this notification at both view controller 1 and view controller 4. Now, when whole modal hierarchy for view controller 1 was up and notification was registered by VC1 and then on top of that another view hierarchy for view controller 4 is shown and finally when notification is thrown both my view hierarchy disappears.
按照我的应用程序流程,我最终要在视图控制器1和视图控制器4上注册此通知。现在,当视图控制器1的整个模式层次结构启动并且VC1注册了通知,然后在另一个视图层次结构之上显示了视图控制器4的视图,最后在引发通知时,我的视图层次结构都消失了。
I want only my top most view hierarchy to be disappeared. 我只希望最顶层的视图层次结构消失。 Any solution for this will really help.
对此的任何解决方案都将真正有帮助。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.