在通常的布局中,咱们先使用一个plist文件,作为tabbarVC的的4个选项 pilist文件以下 而后建立多个Storyboard,以及Storyboard关联的文件, 而后删除启动的一些sb界面,让界面启动时候从AppDelegate中启动, 在AppDelegate中写下以下代码git
<!-- lang: cpp --> - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { // Override point for customization after application launch. self.window = [[UIWindow alloc] initWithFrame:[UIScreen mainScreen].bounds]; self.window.backgroundColor = [UIColor whiteColor]; //b不要在主方法中写碎代码 [self setUI]; [self.window makeKeyAndVisible]; return YES;
}github
-(void)setUI{app
UITabBarController *uiTabBar = [[UITabBarController alloc] init]; NSURL *url = [[NSBundle mainBundle] URLForResource:@"MainUI" withExtension:@"plist"]; NSArray *arr = [NSArray arrayWithContentsOfURL:url]; for (NSDictionary *dic in arr) { UIStoryboard *sb = [UIStoryboard storyboardWithName:dic[@"vcName"] bundle:nil]; UIViewController *uiVC = sb.instantiateInitialViewController; uiVC.title = dic[@"title"]; uiVC.tabBarItem.image = [UIImage imageNamed:dic[@"icon"]]; uiVC.tabBarItem.badgeValue = dic[@"badgeNumber"]; [uiTabBar addChildViewController:uiVC]; } self.window.rootViewController = uiTabBar;
}ide
而后就能看到以下功能了,布局
效果以下 ui
那在SB文件中的按钮点击跳转到其余SB文件中怎么处理呢?以下代码:url
<!-- lang: cpp -->
固然我讲的确定不是很清晰,下面你看下个人源代码吧!嘻嘻,但愿对你有用!code
下面是我在gitthub上详细地址:https://github.com/pyawkk/SB-.git图片