IPad status bar fixed after rotation during video playback

I have a terrible time getting this to work, and the Apple Developer Forum did not help.

I have an application that plays videos, and when moviecontrols are displayed and the iPad rotates, the status bar adheres to the orientation the video was in before the orientation starts. Then at the top of the window there is a gap of 20px, and the status bar is in a different orientation.

Has anyone seen this problem?

Any help would be greatly appreciated.

+3
source share
2 answers

, . , , :

  • MPMoviePlayerWillExitFullscreenNotification
  • , NSTimer, (, 0,1 )
  • do

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

+2

:

  • ()
  • ( presentModalViewController).
  • iPad
  • , "".

Bam! ( - ), , , , .

, :

  • , , 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"); 
    }
}

- , , .

, .

EDIT: performSelector , ( ).

+2

Source: https://habr.com/ru/post/1746453/


All Articles