UITabbar無故消失問題

問題現(xiàn)場是這樣的
切換tab,tabvc內(nèi)嵌navvc,三個tab其中兩個是系統(tǒng)UIVC的,tabbar不隱藏,而有一個自定義的,會隱藏。

frame #0: 0x0000000101893297 palfish_class`-[PFBTabBar setHidden:](self=0x00007fb35822a370, _cmd="setHidden:", hidden=YES) at PFBTabBar.m:135:5
    frame #1: 0x00000001285d4f7e UIKitCore`-[UITabBarController animationDidStop:finished:context:] + 157
    frame #2: 0x00000001285d5717 UIKitCore`-[UITabBarController _hideBarWithTransition:isExplicit:duration:] + 1410
    frame #3: 0x0000000128610cf3 UIKitCore`-[UINavigationController _hideOrShowBottomBarIfNeededWithTransition:] + 958
    frame #4: 0x00000001285d9d76 UIKitCore`-[UITabBarController transitionFromViewController:toViewController:transition:shouldSetSelected:] + 3372
    frame #5: 0x00000001285d3994 UIKitCore`-[UITabBarController _setSelectedViewController:] + 426
    frame #6: 0x00000001285d3730 UIKitCore`-[UITabBarController setSelectedIndex:] + 129

經(jīng)過分析發(fā)現(xiàn),是因?yàn)樽远x的TKVC,的init方法是這樣的

- (instancetype)init
{
    self = [super init];
    if (self) {
        self.hidesBottomBarWhenPushed = YES;
    }
    return self;
}

而初始化時的tabbar

[[TKNavigationController alloc] initWithRootViewController:[TKViewController new]];

因?yàn)槭窃O(shè)置rootVC,起初沒往hidesBottomBarWhenPushed上想,沒認(rèn)為是push。但定位問題后,發(fā)現(xiàn)就是它導(dǎo)致的。initWithRootViewController其實(shí)也是push,將參數(shù)vc作為棧底元素。

Discussion
This is a convenience method for initializing the receiver and pushing a root view controller 
onto the navigation stack. Every navigation stack must have at least one view 
controller to act as the root.

Parameters
The view controller that resides at the bottom of the navigation stack. This object 
cannot be an instance of the UITabBarController class.

Returns
The initialized navigation controller object or `nil` if there was a problem initializing the object.

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

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

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