tabBarController管理多個Storyboard

self.window = [[UIWindow alloc]initWithFrame:[UIScreen mainScreen].bounds];

self.window.backgroundColor = [UIColor whiteColor];

// 2.創建TabBarCongtroller

UITabBarController *tab = [[UITabBarController alloc] init];

// 3.加載Storyboard

UIStoryboard *homeVC =[UIStoryboard storyboardWithName:@"Home" bundle:nil];

UIStoryboard *messageVC =[UIStoryboard storyboardWithName:@"Message" bundle:nil];

UIStoryboard *pointVC =[UIStoryboard storyboardWithName:@"Point" bundle:nil];

UIStoryboard *MineVC =[UIStoryboard storyboardWithName:@"mine" bundle:nil];

//3.5 設置tabBarItem

UINavigationController *homeNav = [homeVC instantiateInitialViewController];

UIViewController *home = homeNav.topViewController;

home.title = @"首頁";

UINavigationController *messageNav = [messageVC instantiateInitialViewController];

UIViewController *message = messageNav.topViewController;

message.tabBarItem.title = @"消息";

message.tabBarItem.image = [UIImage imageNamed:@"1"];

// 4.創建Storyboard添加到TabBarCongtroller中

tab.viewControllers=@[homeNav,messageNav,pointVC.instantiateInitialViewController,MineVC.instantiateInitialViewController];

// 5.設置根控制器

self.window.rootViewController = tab;

// 6.顯示Window

[self.window makeKeyAndVisible];

最后編輯于
?著作權歸作者所有,轉載或內容合作請聯系作者
平臺聲明:文章內容(如有圖片或視頻亦包括在內)由作者上傳并發布,文章內容僅代表作者本人觀點,簡書系信息發布平臺,僅提供信息存儲服務。

推薦閱讀更多精彩內容

  • *7月8日上午 N:Block :跟一個函數塊差不多,會對里面所有的內容的引用計數+1,想要解決就用__block...
    炙冰閱讀 2,553評論 1 14
  • 哦吼吼,又研究了幾天,把FMDB這個封裝好的數據庫搞定了,寫了個簡單的例子,基于FMDB的添刪改查操作,界面很一般...
    lichengjin閱讀 569評論 0 0
  • /* UIViewController is a generic controller base class th...
    DanDanC閱讀 1,862評論 0 2
  • 作者唯一QQ:228544117。。。。。 =========后面的都要新建一個文章 AppDelegate.h ...
    CC_iOS閱讀 961評論 0 0
  • 寫過 Java 程序的同學,一般都遇到過 NullPointerException :) —— 為了不拋出這個異常...
    MiZhou閱讀 66,542評論 12 87