我在xcode 4.2中創建了新的標籤欄項目,並且沒有應用程序委託xib文件。項目有兩個導航控制器。我可以設置標籤欄的名稱,但無法設置圖像。我完全厭倦了很多嘗試。 FirstViewController *firstView = [[FirstViewController alloc] initWithNibName:@"FirstViewController_iPhone" bundle:nil]
無法在Xcode 4.2中設置標籤欄圖像編程
[email protected]"Birthdays";
firstView.tabBarItem.image=[UIImage imageNamed:@"bottomleft.png"];
SecondViewController *secondView = [[SecondViewController alloc] initWithNibName:@"SecondViewController_iPhone" bundle:nil];
[email protected]"Settings";
secondView.tabBarItem.image=[UIImage imageNamed:@"bottomright.png"];
UINavigationController *navController2 = [[UINavigationController alloc] initWithRootViewController:secondView];
navController2.navigationBarHidden=YES;
[viewControllers addObject:navController2];
在這裏你可以看到我得到什麼樣的輸出。
Coneybeare,我也做了同樣的事情,但仍然得到相同的結果。你可以在我的答案中看到圖像。 – josh 2012-07-08 17:56:38
有時xcode無法將文件添加到項目中,可能需要手動刪除並再次添加到xcode – 2012-07-09 06:50:02