How to access the stack in UINavigationController

前端 未结 3 1865
花落未央
花落未央 2021-01-01 13:20

viewControllers

The view controllers currently on the navigation stack.

@property(nonatomic, copy) NSArray *          


        
3条回答
  •  轻奢々
    轻奢々 (楼主)
    2021-01-01 14:05

    Assuming you meant that your navigation controller has three view controllers, you should be able to access the navigation controller from any of three view controllers using self.navigationController.

    So if you want to get the second view controller in the stack, you should do –

    UIViewController * viewController = [self.navigationController.viewControllers objectAtIndex:1];
    

    This is assuming that there are at least two view controllers on the navigation controller.

提交回复
热议问题