作者Testarosa (Testarosa)
看板MacDev
標題[問題] 多個TabBar
時間Sat Oct 6 13:23:14 2012
不好意思 新手發問
我想建立一個四個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
1F:推 johnlinvc:initWithNibName:@"" bundle:[NSBundle mainBundle] 10/06 13:29
2F:→ Testarosa:嗯 錯誤訊息還是一樣耶 我是follow這個影片的範例http:/ 10/06 14:06
4F:推 level39:(略)*v4=[[FourthViewController alloc] init]; 試看看 10/06 14:28
5F:→ Testarosa:感謝各位!! 用了好久終於成功了!! 原來有用Storyboard 10/06 16:04
6F:→ Testarosa:的方法會不一樣!! 10/06 16:04