今天做項目狡忙,從無導(dǎo)航欄頁面跳轉(zhuǎn)包含導(dǎo)航條頁面時,使用的是self.navigationController.navigationBar.hidden = YES; 可是隨著左滑pop回上一級界面時,發(fā)現(xiàn)導(dǎo)航條消失不見滋觉。
首先想到是不是在viewWillAppear中添加一遍導(dǎo)航條不隱藏反惕,結(jié)果不起作用。
隨后就嘗試了self.navigationController.navigationBarHidden = YES湿镀;沒想到立馬就解決了這個問題炕吸。所以想看看這兩個隱藏的區(qū)別。
官方解釋:
navigationBarHidden
A Boolean value that indicates whether the navigation bar is hidden.
Discussion
If YES, the navigation bar is hidden. The default value is NO. Setting this property changes the visibility of the navigation bar without animating the changes. If you want to animate the change,
use the setNavigationBarHidden:animated:method instead.
navigationBar
The navigation bar managed by the navigation controller.
Discussion
It is permissible to customize the appearance of the navigation bar using the methods and properties of the UINavigationBar class but you must never change its frame, bounds, or alpha values or modify its view hierarchy directly.
To show or hide the navigation bar, you should always do so through the navigation controller by changing its navigationBarHidden property or calling the setNavigationBarHidden:animated: method.
同樣都是會調(diào)用setNavigationBarHidden:animated:method 但是卻有著細微的差別勉痴。
在網(wǎng)上查了一下赫模,說的都是navigationBarHidden會隱藏整個navigationController,而navigationBar.hidden作用于nabigationbar蒸矛;
具體情況在官方我還沒有找到瀑罗,但是使用navigationBarHidden能夠解決pop手勢左滑導(dǎo)致導(dǎo)航條空白的問題。
利用pop左滑手勢回去時雏掠,在viewWillDisAppear中打斷點斩祭,lldb查看情況
(lldb) po self.navigationController.navigationBarHidden
false
(lldb) po self.navigationController.navigationBar.hidden
false
可以看出這個時候兩個狀態(tài)是一樣的。
當再次點擊進入下一級頁面時乡话,就可以看到摧玫,兩者的差別
(lldb) po self.navigationController.navigationBarHidden
<nil>
(lldb) po self.navigationController.navigationBar.hidden
false