導(dǎo)航: 狀態(tài)欄 隱藏(hidesBottomBarWhenPushed)

2016-12-16 09:13:19.318 TheStep[1159:150589] *** 
Terminating app due to uncaught exception 'NSInvalidArgumentException', 
reason: 
'Pushing a navigation controller is not supported'


之前

@interface DiscoverViewController : UIViewController

我讓他繼承

正解:

UIViewController * viewController = [[NSClassFromString(objDictionary[kClass]) alloc ] init ];
        BaseItemNaviViewController * navigationViewController = [[BaseItemNaviViewController alloc ] 

在 MainTabBarController 里面改

就不用一個(gè)一個(gè)這樣了

- (void)tapSearchBar
{
    SearchMessgViewController * searchMessgViewController = [[SearchMessgViewController alloc ] init ];
//    searchMessgViewController.hidesBottomBarWhenPushed = YES;
    [self.navigationController pushViewController: searchMessgViewController animated: YES ];


}


感謝簡(jiǎn)書(shū)
iOS+TabBar的隱藏,hidesBottomBarWhenPushed的正確使用

NavigationController重寫(xiě)push方法(學(xué)習(xí)小碼哥的方法)

感謝

iOS:hidesBottomBarWhenPushed的正確用法

Case1:xib加載或者Storyboard用identifier獲取Controller

UIViewController *v2 = [self.storyboard instantiateViewControllerWithIdentifier:@"v2"];
v2.hidesBottomBarWhenPushed = YES;
[self.navigationController pushViewController:v2 animated:YES];

Case2:拉線,也就是Storyboard用performSegue

self.hidesBottomBarWhenPushed = YES;
[self performSegueWithIdentifier:@"tov2" sender:nil];
self.hidesBottomBarWhenPushed = NO;

Tip:經(jīng)測(cè)試證明,此種方式只會(huì)對(duì)后面的一級(jí)生效,繼續(xù)往后Push還會(huì)出現(xiàn)TabBar,要繼續(xù)往后push也隱藏Tabbar還得使用Case3的方法,也建議如此!

Case3:拉線,在prepareForSegue函數(shù)里

-(void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender
{
    [segue.destinationViewController setHidesBottomBarWhenPushed:YES];
}

更方便的做法:如果你在用 Storyboard,可以在 ViewController 的設(shè)置面板中把 Hide Bottom Bar on Push 屬性勾選上,效果和上文代碼一樣。

三種ViewController跳轉(zhuǎn)的異同

最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請(qǐng)聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時(shí)請(qǐng)結(jié)合常識(shí)與多方信息審慎甄別。
平臺(tái)聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點(diǎn),簡(jiǎn)書(shū)系信息發(fā)布平臺(tái),僅提供信息存儲(chǔ)服務(wù)。

相關(guān)閱讀更多精彩內(nèi)容

友情鏈接更多精彩內(nèi)容