多个storyboard实现tabbar

本文介绍了一种在多人协作开发中使用多个Storyboard的方法,以减少因共同编辑同一个Storyboard而产生的代码冲突。通过创建不同的Storyboard文件并为每个Storyboard指定特定的ViewController,可以有效地组织和管理TabBarController中的不同视图。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

当多人协作开发代码时,共同维护一个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];
}


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值