2015-02-09 46 views
1

我有TabbarViewController。在一個選項卡中,當導航到特定的ViewController(詳細圖片視圖)時,我想隱藏狀態欄。 我已閱讀此鏈接: How to hide a status bar in iOS?在特定的視圖控制器中隱藏狀態欄,在TabbarViewController中

但於我而言,這是行不通的,因爲我不想躲藏在整個應用程序的狀態欄,但只是在一個特定的ViewController

是否有一種方法可以在某個標籤中隱藏滾動條?

*編輯: 我想隱藏狀態欄的ViewController是一個PageViewController。這是問題嗎?

+0

我只是編輯您的問題,所以它更容易準確地瞭解你的要求。我希望我正確理解這個問題:)。 – 2015-02-09 12:05:35

+0

試試這個:http://stackoverflow.com/questions/18979837/how-to-hide-ios-7-status-bar – anny 2015-02-09 12:16:07

+0

@ Lea Cohen:非常感謝,我的英語不好。 :) – user2951346 2015-02-09 12:16:47

回答

0

試試下面的代碼:

- (void) viewWillAppear:(BOOL)animated{ 
    [UIApplication sharedApplication].statusBarHidden = YES; 
} 
+0

謝謝。我試過了,但它仍然不起作用 – user2951346 2015-02-09 12:10:37

2
-(void) viewDidAppear:(BOOL)animated{ 
     [super viewDidAppear:YES]; 
     if([UIApplication sharedApplication].statusBarOrientation == UIInterfaceOrientationLandscapeLeft || [UIApplication sharedApplication].statusBarOrientation == UIInterfaceOrientationLandscapeRight){ 
     if ([self respondsToSelector:@selector(setNeedsStatusBarAppearanceUpdate)]){ 
      [self prefersStatusBarHidden]; 
      [self performSelector:@selector(setNeedsStatusBarAppearanceUpdate)]; 
      [[UIApplication sharedApplication] setStatusBarHidden:YES withAnimation:UIStatusBarAnimationSlide]; 
     } 
     else{ 
      // iOS 6 
      [[UIApplication sharedApplication] setStatusBarHidden:YES withAnimation:UIStatusBarAnimationSlide]; 
     } 

    } 
    else if([UIApplication sharedApplication].statusBarOrientation == UIInterfaceOrientationPortrait || [UIApplication sharedApplication].statusBarOrientation == UIInterfaceOrientationPortraitUpsideDown){ 
     if ([self respondsToSelector:@selector(setNeedsStatusBarAppearanceUpdate)]){ 
      [[UIApplication sharedApplication] setStatusBarHidden:YES withAnimation:UIStatusBarAnimationSlide]; 
      [self performSelector:@selector(setNeedsStatusBarAppearanceUpdate)]; 
     } 
     else{ 
      // iOS 6 
      [[UIApplication sharedApplication] setStatusBarHidden:YES withAnimation:UIStatusBarAnimationSlide]; 
     } 
    } 
} 

-(UIStatusBarStyle)preferredStatusBarStyle{ 
    return UIStatusBarStyleLightContent; 
} 
- (BOOL)prefersStatusBarHidden { 
    return YES; 
} 
+0

謝謝,但它仍然不起作用。而我想隱藏狀態欄的ViewController是一個PageViewController,是這樣的問題嗎? – user2951346 2015-02-09 12:15:44

+0

只寫下你想隱藏的這三個函數。 – 2015-02-09 12:20:09

+0

@ Pratik Patel:我的確如你所說,但它不起作用......我只是看到狀態欄的風格改變 – user2951346 2015-02-09 12:26:28

相關問題