2013-10-30 77 views
1

我有這個問題。我在的appDelegate創建的TabBar:不顯示標籤欄圖像

RootViewController *controller = [[RootViewController alloc] initWithNibName:@"RootView" bundle:nil]; 
UINavigationController *rootNavigationController = [[UINavigationController alloc] initWithRootViewController:controller]; 

[其他控制器初始化...]

self.tabController = [[UITabBarController alloc] init]; 
self.tabController.viewControllers = [NSArray arrayWithObjects:rootNavigationController,secondController,thirdController, nil]; 

現在,當在RootViewController的我嘗試指定圖像的TabBar:

- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil { 
self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil]; 
if (self) { 
    self.tabBarItem.image = [UIImage imageNamed:@"tabRoot.png"]; 
    self.tabBarItem.title = @"Root"; 
} 

但是沒有顯示,爲什麼?奇怪的是,如果我做同樣的事情,但沒有navigationController,圖像正確顯示。

+0

爲tabbarItem添加圖片中的appDelegate .. – TamilKing

+0

放破發點,並檢查?我已檢查其工作正常。 –

+0

是的,我檢查過,標籤欄標題和圖像被分配,但不顯示 – Anna565

回答

0

只需使用下面的代碼

[self.tabBarItem setFinishedSelectedImage:[UIImage imageNamed:@"tabRoot.png"] withFinishedUnselectedImage:[UIImage imageNamed:@"tabRoot.png"]]; 
+0

不幸的是不工作 – Anna565