UINavigationController and back button action

后端 未结 7 2036
-上瘾入骨i
-上瘾入骨i 2021-01-04 09:09

I have an two controllers 1st is self and 2nd is maincontroller, where I\'m pushing maincontroller in stack

相关标签:
7条回答
  • 2021-01-04 09:36

    viewControllerCount - is the var that holds the number of viewControllers previously was in the UINavigationController. Then, we check if viewControllerCount > [viewControllers count] if so, we know that we will get back (i.e. Back button imitation).

    - (void)navigationController:(UINavigationController *)navigationController
          willShowViewController:(UIViewController *)viewController
                        animated:(BOOL)animated
    {
        NSArray *viewControllers = [navigationController viewControllers];
    
        if (viewControllerCount > [viewControllers count])
        {
            // your code
        }
    
        viewControllerCount = [viewControllers count];
    }
    
    0 讨论(0)
提交回复
热议问题