How to access the stack in UINavigationController

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

viewControllers

The view controllers currently on the navigation stack.

@property(nonatomic, copy) NSArray *          


        
3条回答
  •  刺人心
    刺人心 (楼主)
    2021-01-01 14:15

    UINavigationControllers have a property called viewControllers as you have stated above. Since this is an array of View Controllers, referencing a specific view controller in this hierarchy is no different than accessing any other object in an array.

    UIViewController *theControllerYouWant = [self.navigationController.viewControllers objectAtIndex:(theIndexOfYourViewController)];
    

    In addition check out the Navigation Controllers article in the iOS Developer Library, specifically the section called 'Modifying the Navigation Stack'.

提交回复
热议问题