How to get a uinavigation bar back button to return to anthother view controller

前端 未结 5 1807
Happy的楠姐
Happy的楠姐 2021-01-16 04:00

How would I go about having a UINavigation controller navigate not to the previous view but the view before that. Basically I would like it to jump back 2 places instead of

5条回答
  •  情深已故
    2021-01-16 04:27

    Add a target to the button you added

    then use the following code to go back more than 1 viewController

    //Get the view controller that is 2 step behind
    UIViewController *controller = [nav.viewControllers objectAtIndex:nav.viewControllers.count - 2];
    
    //Go to that controller
    [nav popToViewController:controller animated:YES];
    

提交回复
热议问题