简体   繁体   English

从子视图调用的UINavigationController中的自定义委托

[英]Custom Delegate in UINavigationController calling from subview

I have a UINavigationController which is presented in a Modal view. 我有一个模态视图中显示的UINavigationController。 I want the view which is presenting the navigationcontroller to be responsible for removing the modal. 我希望呈现导航控制器的视图负责删除模态。 Therefor I created a delegate method on the UINavigationController: 为此,我在UINavigationController上创建了一个委托方法:

@protocol MyNaviDelegate <NSObject>

-(void)userWantsToQuit;

@end

How can I call this delegate method from a subview (lets say if the user is 2 levels deep into the navigationcontroller (like VIEW C)? 我如何从子视图中调用此委托方法(如果用户位于导航控制器深处为2级(例如VIEW C))?

---------------------------------------------------------
| NAVIGATION CONTROLLER                                 |
| --------------     --------------      -------------- |
| |  VIEW A    |  -> |   VIEW B   |  ->  |   VIEW C   | |
| |            |     |            |      |            | |
| --------------     --------------      -------------- |
|                                                       |
---------------------------------------------------------

Thanks in advance! 提前致谢!

You can send Notification on a particular event(from View C) to that controller class in which you are presenting the navigationcontroller. 您可以将特定事件的通知(从View C)发送到要在其中显示navigationcontroller的控制器类。 Then you can remove it. 然后,您可以将其删除。

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

相关问题 自定义委托未从NSURLSessionDelegates调用 - Custom Delegate is not calling from NSURLSessionDelegates 从另一个类调用自定义和委托方法 - calling custom and delegate method from another class 在Swift中从AppDelegate调用自定义委托 - Calling custom delegate from AppDelegate in Swift UIImagePickerController子视图不调用委托。 用作modalViewController - UIImagePickerController Subview Not calling delegate. Works as modalViewController 从UIViewController调用自定义UINavigationController中的方法时目标错误 - Wrong target when calling method in custom UINavigationController from UIViewController 尝试从UISegmentControl中的子视图初始化UINavigationController - Trying to initiate UINavigationController From A Subview in UISegmentControl 如何使用子视图“自定义底部标签栏”对UINavigationController进行子类化 - How to Subclass UINavigationController With a subview Custom Bottom Tab Bar 在subView上委托 - Delegate on subView 使用委托从子视图更改UILabel文本 - Change UILabel text from subview using delegate 从自定义委托中调用self.navigationController会导致null - Calling self.navigationController from custom delegate results in null
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM