How to pop a viewController and then Push a viewController through delegation

后端 未结 5 1063
长情又很酷
长情又很酷 2021-02-09 00:56

I have a UITableViewController that when a cell is pressed, I want the controller to pop itself, and then have the controller it pop\'s to, push another view controller onto the

5条回答
  •  深忆病人
    2021-02-09 01:22

    How about when you dismiss your UIViewController containing the table you send a NSNotifcation in your viewDidDisappear method like so:

    - (void)viewDidDisappear:(BOOL)animated
    {
        [[NSNotificationCenter defaultCenter] postNotificationName:@"loadOtherVC" object:nil];
    }
    

    And in your parent view controller that will push a new view controller, you add an observer for that notification like so:

    [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(LoadOtherVC:) name:@"loadOtherVC" object:nil];
    

    You should have a method that matches the selector.

    - (void) LoadOtherVC:(NSNotification *) notification
    {
        // load your other view controller you want here
    }
    

提交回复
热议问题