statusbar issue on UIWebView embedded YouTube video playback

你说的曾经没有我的故事 提交于 2019-12-07 16:26:52

问题


Playing youtube video as below:

videoView = [[UIWebView alloc] initWithFrame:CGRectMake(10, 50, 300, 215)];
videoView.backgroundColor = [UIColor clearColor];
videoView.opaque = NO;
videoView.delegate = self;
[self.view addSubview:videoView];
NSURLRequest *loadRequest=[NSURLRequest requestWithURL:Your_Youtube_URL];
[videoView loadRequest:loadRequest];

Issue: Statusbar issue on UIWebView embedded YouTube video playback

Steps to produce Status bar issue:

  • When application orientation support is only Portrait.

  • User click to play video on UIWebview embedded youtube video player

  • Device open its default video player to play video and its provide landscape support to play video even if your application has only orientation support portrait

  • Now user change device orientation to landscape to view video in full screen 


  • Now user press Done button to stop video and come back to application

  • In this situation, status bar remain landscape and application screen looks in portrait mode.


回答1:


Solution:

- (void)viewDidLoad
{
…

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

}

- (void)viewDidUnload
{

…

[[NSNotificationCenter defaultCenter] removeObserver:self
                                                    name:@"UIMoviePlayerControllerDidExitFullscreenNotification"
                                                  object:nil];
}

- (void)VideoExitFullScreen:(id)sender{

    [[UIApplication sharedApplication] setStatusBarOrientation:UIInterfaceOrientationPortrait animated:NO];

}


来源:https://stackoverflow.com/questions/21453177/statusbar-issue-on-uiwebview-embedded-youtube-video-playback

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!