Search code examples
iosuinavigationcontrolleruitabbarcontrolleruinavigationitem

navigation back button shows for a while, about 1 second, when switching tabbarcontroller programmatically


I have a UItabbarviewcontroller tabVC as root view controller, and tabA have a navigationcontroller naviA, tabB have a navigationcontroller naviB. naviA and naviB both have a bunch of viewcontrollers.

Now I want to switch from VC1 to VC2 programmatically. VC1 is embeeded in naviA, and VC2 is embeeded in naviB.

Here is what I did:

  1. From VC1, I used pop to root view controller in naviA.
  2. then, I set tabVC selectedIndex to 2, which is tabB.
  3. last, I use pushviewcontroller to navigate to VC2 in naviB.

The problems shows up. when I am pushing to VC2, the system deault backbutton item shows up for about 1 second and disappears.

I set the left bar button item as my custom back button. There shouldn't be a system back button item.

The back button item doesn't shows when I tab the tabviewcontroller and click the button to push to VC2 by my finger(not programmatically).

how to avoid to show the system default back button?


Solution

  • After digging around, My workaround is using [self.navigationController pushViewController:VC2 animated:NO] in step 3 rather than [self.navigationController pushViewController:VC2 animated:YES]

    Should block the animation.