Search code examples
iphoneobjective-cuiwebviewuistatusbar

UIWebView in full screen hides status bar


I am opening video in UIWebView with following code.

- (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]]];
}

but when my mainWebView opens in full screen it hides my status bar.

I don't want to hide status bar

then how can I show my status bar?


Solution

  • You Can set Notification For making Status bar Visible. Set The Notification for FullScreen Entry And Exit Notification ,SO that you could SHow And Hide The Status bar As Needed.

    // 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
     }
    

    I am Sure It'll be helpful to you.