UIWebView 嵌入式 YouTube 视频播放上的状态栏问题 [英] statusbar issue on UIWebView embedded YouTube video playback
问题描述
播放 YouTube 视频如下:
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];
问题: UIWebView 嵌入式 YouTube 视频播放上的状态栏问题
Issue: Statusbar issue on UIWebView embedded YouTube video playback
产生状态栏问题的步骤:
当应用程序方向支持仅纵向时.
When application orientation support is only Portrait.
用户点击以在 UIWebview 嵌入式 YouTube 视频播放器上播放视频
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.
推荐答案
解决方案:
- (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];
}
这篇关于UIWebView 嵌入式 YouTube 视频播放上的状态栏问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!