How do I pop the view controller underneath a pushed view controller?

后端 未结 4 649
清酒与你
清酒与你 2021-02-06 01:36

I want to push a view controller onto the stack, then pop the first one that pushed the new one.

-(void) someMethod {
    MegaSuperAwesomeViewController *tempVC          


        
4条回答
  •  野趣味
    野趣味 (楼主)
    2021-02-06 02:07

    Thanks Bogatyr about the tip on 'party on the viewcontroller array for the navcontroller'. I just replaced the entire stack with the one viewcontroller I want to change to, and then log out all the viewcontrollers in the stack to make sure its the only one! Worked great - thanks!

        RatingsTableViewController *newViewController = [[RatingsTableViewController alloc] init];
        NSMutableArray * newVCarray = [NSMutableArray arrayWithObjects:newViewController, nil];
        self.navigationController.viewControllers = newVCarray;
    
        [newViewController release];
    
         NSMutableArray *allControllers = [[NSMutableArray alloc] initWithArray:self.navigationController.viewControllers];
    
        for (id object in allControllers) {
    
              NSLog(@"name VC: %@", object);
        }
        [allControllers release];
    

提交回复
热议问题