2012-05-20 36 views
3

我正在以具有底部標籤欄的桌面視圖以編程方式構建視圖。 當我選擇一個表單元格時,我希望這個底部條消失。 我能做到這一點使用:如何以編程方式設置「在推入時隱藏底部欄」?

self.tabBarController.tabBar.hidden = YES; 

但視圖的大小仍然是,如果使用TabBar仍然存在。 我發現如果視圖是建立在故事板上的,並且通過設置複選標記「隱藏底部欄」,視圖將調整大小以佔用Tabbar留出的空間。 如何以編程方式執行此操作?

回答

10
self.hidesBottomBarWhenPushed = YES; 
[self.navigationController pushViewController:self.anotherViewController animated:animated]; 

併爲您推送一個特定的視圖控制器。使用此代碼

TheViewController* theController = [[TheViewController alloc] initWithNibName:@"TheViewController" bundle:nil]; 
    theController.hidesBottomBarWhenPushed = YES; 
    [self.navigationController pushViewController:theController animated:YES]; 
    [theController release]; 

現在tabbar將被隱藏並自動顯示。享受時間:)

+1

我這樣做,但問題是,當返回到tableview時tabbar仍然隱藏。完成詳細視圖後,是否有辦法再次顯示該tabbar? –

+0

肯定爲什麼不。在幾秒內看到我編輯的答案 – Saad

+0

現在看第二部分 – Saad

相關問題