[問題] 多個TabBar

看板MacDev作者 (Testarosa)時間12年前 (2012/10/06 13:23), 編輯推噓2(204)
留言6則, 3人參與, 最新討論串1/1
不好意思 新手發問 我想建立一個四個TabBar分頁的控制 AppDelegate.h 的程式碼如下: #import <UIKit/UIKit.h> @interface AppDelegate : UIResponder <UIApplicationDelegate,UITabBarControllerDelegate> @property (strong, nonatomic) UIWindow *window; @property (strong, nonatomic) UITabBarController *tab; @end AppDelegate.m如下: #import "AppDelegate.h" #import "FirstViewController.h" #import "SecondViewController.h" #import "thirdViewController.h" #import "FourthViewController.h" @implementation AppDelegate @synthesize window; @synthesize tab; - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { self.window = [[UIWindow alloc]initWithFrame:[[UIScreen mainScreen]bounds]]; FirstViewController *v1=[[FirstViewController alloc] initWithNibName:@"FirstViewController"bundle:nil]; SecondViewController *v2=[[SecondViewController alloc]initWithNibName:@"SecondViewControler" bundle:nil]; thirdViewController *v3=[[thirdViewController alloc]initWithNibName:@"thirdViewController" bundle:nil]; FourthViewController *v4=[[FourthViewController alloc]initWithNibName:@"FourthViewController" bundle:nil]; self.tab = [[UITabBarController alloc]init]; self.tab.viewControllers = [NSArray arrayWithObjects:v1,v2,v3,v4, nil]; self.window.rootViewController = self.tab; [self.window makeKeyAndVisible]; return YES; } 最後跑出一個錯誤:Could not load NIB in bundle 請問是哪個環節出錯了 謝謝大家!! -- ※ 發信站: 批踢踢實業坊(ptt.cc) ◆ From: 114.34.32.46

10/06 13:29, , 1F
initWithNibName:@"" bundle:[NSBundle mainBundle]
10/06 13:29, 1F

10/06 14:06, , 2F
嗯 錯誤訊息還是一樣耶 我是follow這個影片的範例http:/
10/06 14:06, 2F

10/06 14:28, , 4F
(略)*v4=[[FourthViewController alloc] init]; 試看看
10/06 14:28, 4F

10/06 16:04, , 5F
感謝各位!! 用了好久終於成功了!! 原來有用Storyboard
10/06 16:04, 5F

10/06 16:04, , 6F
的方法會不一樣!!
10/06 16:04, 6F
文章代碼(AID): #1GRy14qf (MacDev)
文章代碼(AID): #1GRy14qf (MacDev)