2014-04-24 78 views
1

我有隱藏UITabBar的問題。我有一個自定義的TabBar我躲使用:iOS 7 - 隱藏tabBar並顯示工具欄,而不是

self.frame = CGRectOffset(tabBarRect, 0, CGRectGetHeight(tabBarRect)); 

相反的TabBar的,我想顯示的工具欄。一切看起來不錯,但我注意到以前由tabBar佔用的區域沒有響應,儘管我偏移了tabBar幀。

所以,我只是把工具欄作爲的TabBar的子視圖:

toolBar.frame = CGRectMake(0, CGRectGetHeight(tbv.frame) - toolBar.intrinsicContentSize.height, CGRectGetWidth(self.view.frame), toolBar.intrinsicContentSize.height); 
    [tbv addSubview:toolBar]; 

不幸的是,我的TabBar比工具欄大,所以我不能使用此解決方案。 我知道我可以將toolBar添加到appDelegate的keyWindow和tabBar的頂部,但是我想將它放在我的viewController中。

有沒有什麼辦法禁用tabBar和使用toolBar或任何其他控件與手勢在當前viewController是導航爲基礎的應用程序與tabBar的一部分?

感謝頤

回答

0

可能你可以嘗試self.hidesBottomBarWhenPushed =YES;

這樣的:

self.hidesBottomBarWhenPushed =YES;//hide controller's tabbar 

UIViewController *controller =[self.storyboard instantiateViewControllerWithIdentifier:@"MyRequirementParticipateInViewController"]; 

[self.navigationController pushViewController:controller animated:YES]; 

self.hidesBottomBarWhenPushed =NO;//when pushed back tabbar would show again. 
+0

感謝傑克,但我需要相同的viewController與可見的TabBar推,然後,如果用戶點擊按鈕,toolBar應該替換tabBar。而我寧可不實例化相同的viewController –