How can I remove a view from navigation controller

前端 未结 5 2054
不思量自难忘°
不思量自难忘° 2020-12-14 11:36

I want to call a new view controller and remove the current view controller from the navigation controller stack. For example. I am in view controller A and I call B.

<
5条回答
  •  失恋的感觉
    2020-12-14 12:14

    To remove the second-from-last navigation item:

    NSMutableArray *navigationStack = [[NSMutableArray alloc] initWithArray: 
        self.navigationController.viewControllers];
    [navigationStack removeObjectAtIndex:[navigationStack count] - 2];
    self.navigationController.viewControllers = navigationStack;
    

    For example, run this from viewDidLoad on controller C to remove controller B from the navigation stack.

提交回复
热议问题