从MPMoviePlayerController隐藏StatusBar [英] Hide StatusBar from MPMoviePlayerController

查看:84
本文介绍了从MPMoviePlayerController隐藏StatusBar的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直在努力解决一个非常讨厌的问题,我希望我能在这个主板上找到帮助。

I've been struggling with a very annoying problem all day long and I hope I could find help on this board.

我正在使用MPMoviePlayerController来玩iPad上的全屏电影我无法想象如何删除始终显示的状态栏,尽管我努力让它下地狱。

I'm using an MPMoviePlayerController to play a fullscreen movie on iPad and I can't figure how to remove the status bar which is always displayed despite all my efforts to make it go to hell.

这是我用来显示电影的方法的代码:

Here is the code of the method I use to display the movie :

-(void)launchVideoFromButton:(id)sender{

         NSString *videoPath = [[NSBundle mainBundle] pathForResource:@"movie01" ofType:@"m4v"];
         NSURL *videoPathURL = [NSURL fileURLWithPath:videoPath];
         moviePlayer = [[MPMoviePlayerController alloc] initWithContentURL:videoPathURL];

         [self.view addSubview:moviePlayer.view];

         moviePlayer.shouldAutoplay = YES;
         moviePlayer.movieSourceType = MPMovieSourceTypeFile;


         [moviePlayer setFullscreen:YES animated:YES];
         moviePlayer.controlStyle = MPMovieControlStyleFullscreen;

         NSNotificationCenter *notificationCenter = [NSNotificationCenter defaultCenter];
         [notificationCenter addObserver:self selector:@selector(moviePlayerEvent:) name:MPMoviePlayerLoadStateDidChangeNotification object:moviePlayer];

    }



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

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

    }

在控制台中,我可以看到moviePlayerEvent在触发时被触发电影出现但状态栏仍然存在:[[UIApplication sharedApplication] setStatusBarHidden:YES withAnimation:NO]似乎无法使用。我一直试图使用其他MPMoviePlayerController通知而没有运气。

In the console, I can see that moviePlayerEvent is fired when the movie appears but the statusbar is still there : [[UIApplication sharedApplication] setStatusBarHidden:YES withAnimation:NO] seems to be inoperant. I've been trying to use the other MPMoviePlayerController notifications with no luck.

有人可以帮助我吗?

提前致谢。

推荐答案

不幸的是,在遇到这个问题后,通过研究和大量实验,我已经确定在全屏模式下隐藏iOS状态栏几乎是不可能的。无论你做什么,当显示全屏播放器控件时,状态栏也会显示(它不会尊重 setStatusBarHidden:YES )。嵌入式播放器控件不是这种情况,但用户可以在嵌入式和全屏模式之间轻松切换,因此在显示控件时,您无法真正使用它来保持状态栏。

Unfortunately, after running into this very problem, through research and much experimentation, I've determined that it is pretty much impossible to keep the iOS status bar hidden in full screen mode. No matter what you do, when the full screen player controls are shown, so will the status bar (it will not respect the setStatusBarHidden:YES). This is not the case with the embedded player controls, but the user can easily switch between embedded and full screen modes, so you can't really use this to maintain no status bar when the controls are shown.

当然,当控件淡出时,状态栏至少会消失......

Of course, at least the status bar goes away when the controls fade out...

这篇关于从MPMoviePlayerController隐藏StatusBar的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆