iPad 状态栏在视频播放期间旋转后粘住

发布于 2024-09-02 00:25:58 字数 167 浏览 4 评论 0原文

我很难让它发挥作用,苹果开发者论坛也没有提供任何帮助。

我有一个播放视频的应用程序,当显示影片控件并且旋转 iPad 时,状态栏会保持在方向开始之前视频所在的方向。然后,视图顶部有一个 20px 的间隙,而状态栏处于另一个方向。

有人见过这个问题吗?

任何帮助将不胜感激。

I am having a terrible time getting this to work, and the Apple Developer forum has been of no help.

I have an application that plays video and when the moviecontrols are displayed and the iPad is rotated, the status bar sticks to the orientation that the video was in before the orientation begins. Then there is a 20px gap at the top of the view while the statusbar in another orientation.

Has anyone seen this problem?

Any help would be greatly appreciated.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

梦与时光遇 2024-09-09 00:25:58

我遇到了同样的问题,而且在将电影播放器​​返回到窗口模式后,我的视图仍然混乱。我不知道如何在全屏播放期间解决这个问题,但至少在切换回窗口后,您可以像这样修复状态栏:

  • 在通知回调函数中注册 MPMoviePlayerWillExitFullscreenNotification 的观察者
  • ,启动 NSTimer 来调用另一个函数位(如 0.1 秒)稍后
  • 在计时器函数中执行

    [[UIApplicationsharedApplication]setStatusBarOrientation:[[UIDevice currentDevice]orientation]animated:NO];

I had the same issue, plus my view was still screwed up after returning the movie player to windowed mode. I don't know how to fix this during fullscreen play, but at least after switching back to windowed you can fix up the status bar like this:

  • register an observer for MPMoviePlayerWillExitFullscreenNotification
  • in the notification callback function, launch an NSTimer to call another function a bit (like 0.1s) later
  • in the timer function do

    [[UIApplication sharedApplication] setStatusBarOrientation:[[UIDevice currentDevice] orientation] animated:NO];

樱娆 2024-09-09 00:25:58

我遇到了同样的问题:

  • 以纵向启动应用程序(例如)
  • 启动视频播放器(我们的使用 presentModalViewController 显示)。
  • 旋转 iPad
  • 按“完成”

退出视频。嘭!我们的应用程序的布局被破坏(我们为每个方向做了一些自定义布局),并且状态栏位于错误的位置,尽管在视频中处于正确的位置。

我做了两件事来解决这两个问题:

  • 确保在 viewWillAppear 中完成的自定义配置是在调用 [super viewWillAppear]; 之后完成的。
  • 实现 MPMoviePlayerDidExitFullscreenNotification 和 MPMoviePlayerPlaybackDidFinishNotification 的观察者(在我的例子中,单击“完成”时,第一个观察者从未被调用)。

观察者回调的代码如下所示:

[self performSelector: @selector(checkAndFixStatusBar)
           withObject: nil
           afterDelay: 0];

[[NSNotificationCenter defaultCenter] removeObserver: self];

最后的方法,在有意的 0 延迟后调用:

- (void)checkAndFixStatusBar
{
    UIInterfaceOrientation intOrient = self.interfaceOrientation;
    UIInterfaceOrientation sbOrient = [[UIApplication sharedApplication] statusBarOrientation];

    if (intOrient != sbOrient)
    {
        [[UIApplication sharedApplication] setStatusBarOrientation: intOrient animated: NO];
        NSLog(@"Fixed status bar orientation"); 
    }
}

状态栏仍然有明显的闪烁,但这是我想到的最好的方法。

希望这有帮助。

编辑:我已经删除了performSelector步骤,并直接调用状态栏设置,在我的情况下,它没有明显的区别(仍然闪烁)。

I had the same problem:

  • start application in portrait (for instance)
  • launch video player (ours is shown using presentModalViewController).
  • rotate iPad
  • exit video by pressing 'Done'.

Bam! Our application's layout is broken (we do some custom layout for each orientation), and the status bar is at the wrong place, despite being at the correct place when in video.

I did two things to fix the two issues :

  • make sure our custom configuration, which is done in viewWillAppear, is done AFTER calling [super viewWillAppear];.
  • implement observers for MPMoviePlayerDidExitFullscreenNotification and MPMoviePlayerPlaybackDidFinishNotification (the first one never got called when clicking 'Done' in my case).

The code for the observer's callback is looking like this:

[self performSelector: @selector(checkAndFixStatusBar)
           withObject: nil
           afterDelay: 0];

[[NSNotificationCenter defaultCenter] removeObserver: self];

And the final method, called after an intentional 0 delay:

- (void)checkAndFixStatusBar
{
    UIInterfaceOrientation intOrient = self.interfaceOrientation;
    UIInterfaceOrientation sbOrient = [[UIApplication sharedApplication] statusBarOrientation];

    if (intOrient != sbOrient)
    {
        [[UIApplication sharedApplication] setStatusBarOrientation: intOrient animated: NO];
        NSLog(@"Fixed status bar orientation"); 
    }
}

There is still a perceivable blinking of the status bar, but that's the best I came up with.

Hope this helps.

EDIT: I've removed the performSelector step, and directly called the status bar setup, in my case, it makes no noticeable difference (still blinking).

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文