-1

这是我的代码:

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
    self.window = [[[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]] autorelease];

    CSDisplayPlaza *displayPlaza = [[CSDisplayPlaza alloc] initWithNibName:@"CSDisplayPlaza" bundle:nil];
    [displayPlaza setTabBarItem:[[UITabBarItem alloc] initWithTitle:@"one" image:[UIImage imageNamed:@"displayPlaza"] tag:0]];
    UINavigationController *displayPlazaNav = [[UINavigationController alloc] initWithRootViewController:displayPlaza];

    CSGameHall *gameHall = [[CSGameHall alloc] initWithNibName:@"CSGameHall" bundle:nil];
    [gameHall setTabBarItem:[[UITabBarItem alloc] initWithTitle:@"two" image:[UIImage imageNamed:@"displayPlaza"] tag:1]];
    UINavigationController *gameHallNav = [[UINavigationController alloc] initWithRootViewController:gameHall];

    CSMyInformation *myInformation = [[CSMyInformation alloc] initWithNibName:@"CSMyInformation" bundle:nil];
    [myInformation setTabBarItem:[[UITabBarItem alloc] initWithTitle:@"three" image:[UIImage imageNamed:@"myInformation"] tag:2]];
    UINavigationController *myInformationNav = [[UINavigationController alloc] initWithRootViewController:myInformation];

    self.tabBarController = [[UITabBarController alloc] init];
    [tabBarController setViewControllers:[NSArray arrayWithObjects:displayPlazaNav,gameHallNav,myInformationNav,nil]];
    [tabBarController setSelectedViewController:displayPlazaNav];
    self.window.rootViewController = self.tabBarController;

    [self.window makeKeyAndVisible];
    return YES;
}

在模拟器中,无法显示任何视图控制器。在我的模拟器中只是一个空的标签栏。我不知道会发生什么。

4

1 回答 1

0

我的猜测是 displayPlaza 出于某种原因为零。创建每个对象后添加日志消息以验证您是否确实创建了一个对象,以及选项卡栏控制器数组。

于 2012-09-23T13:32:49.600 回答