2014-06-20 45 views
0

我有rootViewController - UINavigationController。 如您所知UINavigationControllerUINavigationBar。 在iOS 7 UINavigationBar可能與barPosition topAttached。 我想通過點擊按鈕來隱藏ON/OFF狀態欄。但我也希望UINavigationBar應該總是barPositionTopAttached。用UINavigationBar隱藏狀態欄barPositionTopAttached

- (BOOL)prefersStatusBarHidden { 
    return __statusBarHidden; 
} 

- (IBAction)tapShowPhotosButton:(id)sender { 
    __statusBarHidden = !__statusBarHidden; 
    [self setNeedsStatusBarAppearanceUpdate]; 
} 

現在UINavigationBar改變barPositiontopAttached頂部,等等。

回答

0

我寫信給技術支持自動移動,並得到下一個答案:

至於文檔中所述,當欄需要知道其在新窗口中的位置時,調用-positionForBar。當狀態欄隱藏或取消隱藏時不會調用它。導航控制器處理響應狀態欄更改而調整導航欄的大小。不幸的是,UINavigationController沒有提供任何API來定製導航欄調整行爲。

0

試試這個:

- (IBAction)tapShowPhotosButton:(id)sender 
{ 
    __statusBarHidden = !__statusBarHidden; 
    [[UIApplication sharedApplication] setStatusBarHidden:__statusBarHidden withAnimation:UIStatusBarAnimationSlide]; 
    [self setNeedsStatusBarAppearanceUpdate]; 
} 

導航欄應與狀態欄