全屏UIWebView隐藏状态栏
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了全屏UIWebView隐藏状态栏相关的知识,希望对你有一定的参考价值。
我在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全屏打开时,它会隐藏我的状态栏。
我不想隐藏状态栏
那么我该如何显示我的状态栏呢?
答案
您可以设置通知使状态栏可见。设置全屏输入和退出通知的通知,以便您可以显示和隐藏状态栏按需要。
// 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
}
我当然对你有所帮助。
另一答案
这是内置电影播放器AFAIK的行为,你不能改变它...也许用另一种html5控件。
另一答案
当你的UIWebView
开始全屏时,写下这一行..
试试这条线..
-(void)moviePlayerEvent:(NSNotification*)aNotification{
[[UIApplication sharedApplication] setStatusBarHidden:NO withAnimation:NO];
NSLog(@"%i", [UIApplication sharedApplication].statusBarHidden);
}
另一答案
其他方式:
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(VideoFullScreenExit:) name:UIWindowDidBecomeHiddenNotification object:self.view.window];
- (void)VideoFullScreenExit:(id)sender {
[[UIApplication sharedApplication] setStatusBarHidden:NO];
}
以上是关于全屏UIWebView隐藏状态栏的主要内容,如果未能解决你的问题,请参考以下文章