我正在寫這個應用程序有一個問題。UITabBarItems UITabBar顯示後,我沒有點擊該項目時應用程序啓動
我在我的應用程序窗口中設置了UITabBar
,並在視圖文件中設置了圖標。 但是,當我運行應用程序,第一個圖標顯示(因爲視圖加載我猜),其他圖標才顯示,直到我點擊它們。
我需要在其他方法中使用self.tabBarItem
而不是viewDidLoad
?
在此先感謝大家!
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
tabBar = [[UITabBarController alloc] init];
SubscriptionsController *subscriptionsController = [[SubscriptionsController alloc] init];
FavoritesController *favoritesController = [[FavoritesController alloc] init];
CategoriesController *categoriesController = [[CategoriesController alloc] init];
TagsController *tagsController = [[TagsController alloc] init];
HelpScreenController *helpScreenController = [[HelpScreenController alloc] init];
tabBar.viewControllers = [NSArray arrayWithObjects:
subscriptionsController,
favoritesController,
categoriesController,
tagsController,
helpScreenController,
nil
];
[window addSubview:tabBar.view];
// Override point for customization after application launch.
[window makeKeyAndVisible];
return YES;
}
//The View
- (void)viewDidLoad {
[super viewDidLoad];
tabIcon = [[UITabBarItem alloc] initWithTitle:@"Abonime" image:[UIImage imageNamed:@"subscr.png"] tag:0];
self.tabBarItem = tabIcon;
[tabIcon release];
}
非常感謝! :)它的工作完美無缺:) – Olsi 2010-12-11 21:17:59
我如何在swift 2中做到這一點? – deepakssn 2015-10-27 06:22:28
這仍然解決了Swift中的問題 - 7年後。 – SQLiteNoob 2017-09-28 17:11:36