当多人协作开发代码时,共同维护一个storyboard往往会在提交代码时产生不太友好的冲突。这时可以用多个storyboard,每个人维护自己的storyboard,这样就可以有效解决冲突的问题。以下就是简略的代码,用多个storyboard来完成tabbar的各个分支。
#import "ViewController.h"
@interface ViewController ()
@end
@implementation ViewController
- (void)viewDidLoad {
[super viewDidLoad];
// Do any additional setup after loading the view, typically from a nib.
NSMutableArray *vcs = [[NSMutableArray alloc]init];
UIStoryboard *story_first = [UIStoryboard storyboardWithName:@"first" bundle:nil];
UIStoryboard *story_second = [UIStoryboard storyboardWithName:@"second" bundle:nil];
UIViewController *firstViewController = [story_first instantiateViewControllerWithIdentifier:@"first-a"];
UIViewController *secondViewControoler = [story_second instantiateViewControllerWithIdentifier:@"second-a"];
firstViewController.tabBarItem.title = @"1";
secondViewControoler.tabBarItem.title = @"2";
[vcs addObject:firstViewController];
[vcs addObject:secondViewControoler];
[self setViewControllers:vcs];
}