Change tabbarController's tab programmatically with animation

后端 未结 3 1240
不知归路
不知归路 2021-01-14 16:11

I want to change tab through code with animation. Exact scenario is that there are 2 tabs with below hierarchy.

First tab
  - Navigation controller
    - Log         


        
3条回答
  •  灰色年华
    2021-01-14 16:24

    I'm Sorry Geek, I was disconnected on weekend.

    The solution that I took in my app was make a method which call to the popToRootViewControllerAnimated: and then send a performSelector: message to self passing that created method as a selector:

    - (void)delayPopAnimation {
        [self.navigationController popToRootViewControllerAnimated:YES];
    }
    
    // in logoutButtonPressed make some like this
    self.tabBarController.selectedIndex = 0;
    [self performSelector:@selector(delayPopAnimation) withObject:nil afterDelay:1.5];
    

    Maybe it is not the best and well performed solution, but it's an option because do the work. It will select the tab and after a 1.5 second delay, the animation will take place. Hope it helps.

提交回复
热议问题