Determine if view that appears was pushed or came from back button in navigation bar

前端 未结 3 979
天命终不由人
天命终不由人 2021-02-20 05:55

Is there a way to tell if a new controller came from a navigation back button or was pushed onto the stack? Id like to reload data only for pushing on the navigation stack, not

3条回答
  •  执念已碎
    2021-02-20 06:28

    You could implement the UINavigationControllerDelegate and override the `navigationController:didShowViewController:animated:' method. You'll then have to check the returned view controller to make a determination as to whether you came back from the expected view controller.

    - (void)navigationController:(UINavigationController*)navigationController didShowViewController:(UIViewController*)viewController animated:(BOOL)animated
    {
        if (yourPushedViewController == viewController)
        {
            // Do something
        }
    }
    

提交回复
热议问题