简体   繁体   中英

Custom Delegate in UINavigationController calling from subview

I have a UINavigationController which is presented in a Modal view. 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:

@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)?

---------------------------------------------------------
| 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. Then you can remove it.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM