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

后端 未结 5 1082
长情又很酷
长情又很酷 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:38

    The cleanest way to do more than a single push or pop of a view controller is to set the UINavigationControllers view controllers array.

    For example, to pop and then push a view controller:

    MyTableViewController *vc = [[MyTableViewController alloc] init];
    
    NSMutableArray *controllers = [NSMutableArray arrayWithArray:self.navigationController.viewControllers];
    [controllers removeLastObject];
    [controllers addObject:vc];
    
    [self.navigationController setViewControllers:controllers animated:YES];
    

提交回复
热议问题