全屏UIWebView隐藏状态栏

时间:2012-11-20 10:51:05

标签: iphone objective-c uiwebview uistatusbar

我在UIWebView中使用以下代码打开视频。

- (BOOL)webView:(UIWebView *)webView shouldStartLoadWithRequest:(NSURLRequest *)request navigationType:(UIWebViewNavigationType)navigationType
{
    NSLog(@"Navigatin Type %d %@",navigationType, request);
    if (navigationType == 0) {
        self.navigationItem.leftBarButtonItem = backBarBtn;
        [self showVideoInWebView:[request.URL absoluteString]];
        return NO;
    }

    return YES;
}

-(void)showVideoInWebView:(NSString *)urlStr
{
    [mainWebView loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:urlStr]]];
}

但是当我的mainWebView全屏打开时,它会隐藏我的状态栏。

我不想隐藏状态栏

然后如何显示我的状态栏?

4 个答案:

答案 0 :(得分:1)

您可以设置通知使状态栏可见。 设置全屏输入和退出通知的通知,以便您可以根据需要显示和隐藏状态栏。

// For FullSCreen Entry 

[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(videoFullScreen:) name:@"UIMoviePlayerControllerDidEnterFullscreenNotification" object:nil];

// For FullSCreen Exit
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(videoExitFullScreen:) name:@"UIMoviePlayerControllerDidExitFullscreenNotification" object:nil];


- (void)videoFullScreen:(id)sender
   {
     [[UIApplication sharedApplication] setStatusBarHidden:NO animated:NO];

   }

- (void)videoExitFullScreen:(id)sender
 {
  //Here do WHat You want
 }

我肯定会对你有所帮助。

答案 1 :(得分:0)

这是内置电影播放器​​AFAIK的行为,你无法改变它......可能还有另一种HTML5控件。

答案 2 :(得分:0)

当你的UIWebView开始全屏时,写下这一行......

试试这条线..

-(void)moviePlayerEvent:(NSNotification*)aNotification{

     [[UIApplication sharedApplication] setStatusBarHidden:NO withAnimation:NO];
     NSLog(@"%i", [UIApplication sharedApplication].statusBarHidden);

}

答案 3 :(得分:0)

另一种方式:

[[NSNotificationCenter defaultCenter] addObserver:self                                             
selector:@selector(VideoFullScreenExit:) name:UIWindowDidBecomeHiddenNotification object:self.view.window];

- (void)VideoFullScreenExit:(id)sender {
    [[UIApplication sharedApplication] setStatusBarHidden:NO];
}