2011-02-09 63 views
1

我試圖添加一個信息按鈕到UITabBarController生成超過5個選項卡時更多屏幕。我正在使用的代碼是這樣的:將信息按鈕添加到UITabBarController的更多屏幕

// Add the info button to the more controller 
UIButton *infoButton = [UIButton buttonWithType:UIButtonTypeInfoLight]; 
UIBarButtonItem *infoBarButton = [[[UIBarButtonItem alloc] initWithCustomView:infoButton] autorelease]; 
tabBarController.moreNavigationController.navigationItem.leftBarButtonItem = infoBarButton; 

這樣的事情似乎好工作與其他UIViewControllers,但在這種情況下,代碼生成並運行良好,但從來沒有出現的按鈕。

任何想法可能需要改變才能使其工作?

回答

5

啊哈!我需要訪問moreNavigationController堆棧中的第一個項目,而不是moreNavigationController本身。

tabBarController.moreNavigationController.topViewController.navigationItem.leftBarButtonItem = infoBarButton;