2

您好,我想使用 X-code 在 iPhone 中创建一个标签栏应用程序。我有一个初始屏幕,然后我有我的主屏幕,我想在该视图中创建标签栏。所以,我在 ViewDidLoad 方法中创建了一个标签栏。

- (void)viewDidLoad {
    NSLog(@"in Home");
    tabBarController = [[UITabBarController alloc] init];        
    homeViewController = [[HomeViewController alloc]init];  
    NextViewController = [[NextViewController alloc]init];   

    tabBarController.viewControllers = [NSArray arrayWithObjects:homeViewController,nextViewController,nil];    
     window = [[UIWindow alloc] initWithFrame:[UIScreen mainScreen].bounds];
     [window addSubview:tabBarController.view];                                             
     [window makeKeyAndVisible]; 

    [super viewDidLoad];
}

现在,当我编译和运行时,它会一次又一次地调用 HomeView,当我点击第二个选项卡时,它不会调用 NextView。

那么,这段代码有什么问题请帮助我..

4

2 回答 2

1

Can I recommend that you start a new project from the Tab Bar Application template just to look at how it's done when it's done right? You might even keep that and retrofit your splash screen into it.

于 2009-06-27T08:22:05.963 回答
1

你不是一次又一次地添加 homeViewController,因为 viewDidLoad 在 homeViewController 中......

于 2009-06-27T07:08:42.587 回答