ios - 如何使状态栏在 iOS 的 MPMoviePlayerController 中不消失?
<p><p>在 MPMoviePlayerController 中,当控件消失时,甚至状态栏也会随之消失。由于我希望即使控件消失也能显示状态栏,所以我放置了以下代码</p>
<p><code>[ setStatusBarHidden:NO];</code>
但是上面的代码没有任何区别,状态栏随着播放器控件消失。如何解决这个问题呢。 </p>
<p>请找到下面的代码,并告诉我如何纠正它。 </p>
<pre><code>- (void) readyPlayer {
mp =[ initWithContentURL:movieURL];
if ()
{
// Set movie player layout
;
;
// May help to reduce latency
;
// Register that the load state changed (movie is ready)
[ addObserver:self selector:@selector(moviePlayerLoadStateChanged:) name:MPMoviePlayerLoadStateDidChangeNotification object:nil];
} else {
[ addObserver:self selector:@selector(moviePreloadDidFinish:) name:MPMediaPlaybackIsPreparedToPlayDidChangeNotification
object:nil];
}
// Register to receive a notification when the movie has finished playing.
[ addObserver:self selector:@selector(moviePlayBackDidFinish:) name:MPMoviePlayerPlaybackDidFinishNotification object:nil];
}
- (void) moviePlayerLoadStateChanged:(NSNotification*)notification {
NSLog(@"moviePlayerLoadStateChanged");
// Unless state is unknown, start playback
if ( != MPMovieLoadStateUnknown)
{
// Remove observer
[ removeObserver:selfname:MPMoviePlayerLoadStateDidChangeNotification
object:nil];
[ setStatusBarHidden:NO];
// Rotate the view for landscape playback
[ setBounds:CGRectMake(0, 0, 768, 1000)];
// Set frame of movieplayer
[ setFrame:CGRectMake(0, 0, 768, 1000)];
// Add movie player as subview
[ addSubview:];
// Play the movie
;
}
}
- (void) moviePreloadDidFinish:(NSNotification*)notification {
// Remove observer
NSLog(@"moviePreloadDidFinish");
[ removeObserver:nil
name:MPMediaPlaybackIsPreparedToPlayDidChangeNotification
object:nil];
[ setStatusBarHidden:NO];
// Play the movie
;
}
- (void) moviePlayBackDidFinish:(NSNotification*)notification {
NSLog(@"moviePlayBackDidFinish");
[ setStatusBarHidden:NO];
// Remove observer
[ removeObserver:self name:MPMoviePlayerPlaybackDidFinishNotification
object:nil];
;
}
</code></pre></p>
<br><hr><h1><strong>Best Answer-推荐答案</ strong></h1><br>
<p><p>这是一个众所周知的 <code>MPMovieControlStyleFullscreen</code> 问题。只需使用 <code>MPMovieControlStyleEmbedded</code> controlStyle 就可以了。</p>
<p>顺便说一句,对于嵌入式使用来说,这就是更合适的 <code>controlStyle</code>。</p></p>
<p style="font-size: 20px;">关于ios - 如何使状态栏在 iOS 的 MPMoviePlayerController 中不消失?,我们在Stack Overflow上找到一个类似的问题:
<a href="https://stackoverflow.com/questions/8211581/" rel="noreferrer noopener nofollow" style="color: red;">
https://stackoverflow.com/questions/8211581/
</a>
</p>
页:
[1]