我有UITabBarController(選項卡1)內的UINavigationController。當我進入第二個視圖(仍在標籤1中)時,如何使標籤欄消失?我可以使用後退按鈕導航,標籤欄將重新出現。UITabBarController與UINavigationController
1
A
回答
4
self.hidesBottomBarWhenPushed = YES; 將此行放在您瀏覽的位置(在推送操作之前)。
and self.hidesBottomBarWhenPushed = NO; 在viewWillDisappear從您推其他視圖的相同頁面。
它確實有效。在-viewDidLoad
方法
self.hidesBottomBarWhenPushed = YES;
:
1
在的viewController被推,放。它屬於'孩子'風險投資,而不是風險投資。你不需要在其他地方設置它。
0
我喜歡使用視圖控制器的init方法來隱藏底部欄等等。使行爲更好地封裝。
(注:以下是ARC友好的代碼,因此沒有autorelease
來電或retain
/release
雙。)
#pragma mark - UIViewController
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil {
// We must handle this as it's the designated initializer for UIViewController.
// Pay no attention to the params. We're going to override them anyway.
return [self init];
}
#pragma mark - NSObject
- (id)init {
// Why hello there, superclass designated initializer! How are you?
if ((self = [super initWithNibName:@"YourNibNameHere" bundle:nil])) {
// This is a perfect oppy to set up a number of things, such as ...
// ... the title (since you're in a nav controller).
self.navigationItem.title = @"Your Nav Title";
// ... your bottom bar hiding (takes effect once pushed onto your nav controller).
self.hidesBottomBarWhenPushed = YES;
// ... and your tab bar item (since you're in a tab bar controller).
[self setTabBarItem:[[UITabBarItem alloc] initWithTitle:@"Item Title" image:[UIImage imageNamed:@"itemIcon.png"] tag:itemTag]];
}
return self;
}
現在,所有你需要做的就是alloc
/init
您的視圖控制器,並呼籲-pushViewController:animated:
。沒有麻煩,沒有大驚小怪。
當VC彈出時,您的底欄將返回。 (Promise)
這項技術的信用歸於Big Nerd Ranch的Joe Conway。 (這是我從中學到了這個了不起的模式的人。)
至於使用點符號與不是,那麼,這是一個完全不同的討論。因人而異。 ;)
相關問題
- 1. UINavigationController,rootViewController與UITabBarController
- 2. UINavigationController + UITabBarController + UISegmentedControl與TableView/MapView
- 3. Uitabbarcontroller和uinavigationcontroller howto
- 4. 的UITabBarController UINavigationController的中
- 5. 嵌入UINavigationController的UITabBarController
- 6. 的UITabBarController和UINavigationController的
- 7. UITabBarController和UINavigationController交互
- 8. iphone應用程序與uinavigationcontroller和uitabbarcontroller
- 9. UISearchDisplayController,UINavigationController的,的UITabBarController愁楚
- 10. UITabBarController + UINavigationController問題xcode項目
- 11. UITabBarController中的隱藏的UINavigationController
- 12. UITabBarController裏面的UINavigationController問題
- 13. 來自UITabBarController內的popView UINavigationController
- 14. MonoTouch UITabBarController和UINavigationController標題
- 15. iPhone UITabBarController裏面的UINavigationController?
- 16. 添加一個UINavigationController到的UITabBarController
- 17. 是否可以從UINavigationController中推送UITabbarController?
- 18. 編輯按鈕裏面的UITabBarController和UINavigationController
- 19. UITabBarController中的UINavigationController視覺問題
- 20. popToRoot UINavigationController當開關選項卡在UITabbarController
- 21. 如何在UITabBarController中插入UINavigationController
- 22. UINavigationController是否可以包含UITabbarController?
- 23. 在UITabBarController和UINavigationController之間切換
- 24. 使用UINavigationController pushViewController:動畫:推UITabBarController
- 25. 的UITabBarController,UINavigationController的和自動旋轉
- 26. 如何presentModalViewController嵌套的UITabBarController和UINavigationController的
- 27. 如何從UINavigationController彈出時卸載UITabBarController?
- 28. 應用程序設計:UITabBarController裏面UINavigationController
- 29. 我如何與一個UINavigationController工作作爲一個的UITabBarController
- 30. 我怎麼能去頂級的UINavigationController在一個的UITabBarController在其他的UITabBarController UINavigationController的另一個?
謝謝。是自我的navcontroller? – Adele 2010-12-09 04:40:44