Setting the default tab when using storyboards

前端 未结 12 943
执笔经年
执笔经年 2020-12-12 16:27

Can anyone please tell me how to set the default tab when using storyboards in iOS. I can\'t seem to figure out how to accomplish this.

Thank you

12条回答
  •  甜味超标
    2020-12-12 16:42

    My variant is suitable when you want just change the default selected controller, no more customizing. Just add the follow category:

    //  UITabBarController+DefaultPage.h
    #import 
    
    @interface UITabBarController(DefaultPage)
    
    @end
    
    
    //  UITabBarController+DefaultPage.m
    #import "UITabBarController+DefaultPage.h"
    
    @implementation UITabBarController(DefaultPage)
    
    - (void)viewDidLoad {
        [super viewDidLoad];
    
        self.selectedIndex = 1;
    }
    
    @end
    

    p.s: I prefer @joshua-finch answer

提交回复
热议问题