这是我的代码:
- (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;
}
在模拟器中,无法显示任何视图控制器。在我的模拟器中只是一个空的tabbar。我不知道会发生什么。
答案 0 :(得分:0)
我的猜测是displayPlaza由于某种原因是零。创建每个对象后添加日志消息以验证您实际创建了一个对象,还有标签栏控制器数组。