問題現(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.