0

我正在使用以下代码在 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

4 回答 4

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
 }

我相信它会对你有所帮助。

于 2012-11-20T11:07:50.787 回答
0

这是内置电影播放器​​ AFAIK 的行为,您无法更改它......也许可以使用替代 HTML5 控件。

于 2012-11-20T10:56:18.013 回答
0

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

试试这条线..

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

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

}
于 2012-11-20T10:56:36.780 回答
0

其他方式:

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

- (void)VideoFullScreenExit:(id)sender {
    [[UIApplication sharedApplication] setStatusBarHidden:NO];
}
于 2019-04-27T09:30:16.143 回答