我正在創建選項卡式應用程序,並且在選項卡上顯示圖標時遇到了一些麻煩。我將我的代碼與我在本書中研究過的前一個示例進行了比較,它似乎匹配,但新應用程序中的圖標僅顯示爲空白方塊。我試圖將所有相關的代碼都包含進來,但是如果您希望看到更多內容,只需詢問一下,然後根據需要編輯更多內容。我已經檢查過imageNamed:string和圖標名稱的情況是相同的。XCode選項卡式應用程序不會加載圖標
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
... // initializers for ViewControllers 1-3, which are custom viewControllers
// that have the tab properties set in (void)viewDidLoad
globalUINavigationController = [[UINavigationController alloc] initWithNibName:
@"DemoTabbedFourthViewController" bundle:nil];
globalUINavigationController.title = NSLocalizedString(@"Fourth", @"Fourth");
globalUINavigationController.tabBarItem.image = [UIImage imageNamed:@"fourth.png"];
UIViewController *viewController4 = [[DemoTabbedFourthViewController alloc]
initWithNibName:@"DemoTabbedFourthViewController" bundle:nil];
[globalUINavigationController pushViewController:viewController4 animated:YES];
self.tabBarController = [[UITabBarController alloc] init];
self.tabBarController.viewControllers = [NSArray arrayWithObjects:viewController1, viewController2,
viewController3, globalUINavigationController, nil];
self.window.rootViewController = self.tabBarController;
[self.window makeKeyAndVisible];
}
我使用的globalUINavigationController作爲我的榜樣,因爲如果我能得到一個工作,我應該能夠得到別人的工作基礎上。如果您對代碼有任何問題或意見,請告訴我。我是Objective C和iPhone App開發的新手,我會盡我所能的幫助。
你是對的,我需要讓他們成爲不同的圖像類型。該文章有兩個樣本圖像適合我。謝謝你的幫助! – Chance 2012-07-26 16:33:22