How do I set selected tab in UITabBarController using StoryBoard?

前端 未结 10 1446
一整个雨季
一整个雨季 2020-12-31 00:38

How can I switch to some tab in UITabBarController using StoryBoard? I have tried the code below but without success (the tab is not selected):

         


        
10条回答
  •  隐瞒了意图╮
    2020-12-31 00:58

    This will work in stroryboard too...

    [self.tabBarController setSelectedIndex:3]; with this add UITabBarControllerDelegate in .h

    and then use this delegate method

    - (BOOL)tabBarController:(UITabBarController *)theTabBarController shouldSelectViewController:(UIViewController *)viewController
    {
        return (theTabBarController.selectedViewController != viewController);
    }
    

提交回复
热议问题