我有一个 TabBarController 并在我的代码中定义了两个选项卡,例如:
NSMutableArray *viewControllerArray = [[NSMutableArray alloc]initWithCapacity:2];
DisplayMarketViewController *displayMarketViewController = [[DisplayMarketViewController alloc]init];
[viewControllerArray addObject:displayMarketViewController];
[displayMarketViewController release];
DisplayDifferenceMarketViewController *displayDifferenceMarketViewController = [[DisplayDifferenceMarketViewController alloc]init];
[viewControllerArray addObject:displayDifferenceMarketViewController];
[displayDifferenceMarketViewController release];
myTabBarController.viewControllers = viewControllerArray;
在我的 DisplayMarketViewController.m
self.tabBarItem.title = @"Tab1";
UIImage *image = [UIImage imageNamed:@"1.png"];
self.tabBarItem.image =image;
和 DisplayDifferenceMarketViewController.m
self.tabBarItem.title = @"Tab2";
UIImage *image = [UIImage imageNamed:@"2.png"];
self.tabBarItem.image =image;
但在点击选项卡项目之前,Tab2 不会显示。我该如何解决这个问题?