Question

I have an app that is only Portrait but in one view I display a video. That video is

presented as a modal view controller in fullscreen.

Once the user start playing video, this view can be rotated to landscape. I have configured that when the user taps "Done" button, the view is dismissed but the status bar remains in landscape mode.

I have tried to add setStatusBarOrientation on the viewWillAppear on the viewcontroller

that displays the modal view and that doesn't work.

The only thing that is working is if I use:

[[UIDevice currentDevice] setOrientation:UIInterfaceOrientationLandscapeRight];

but I've heard that Apple might reject the app if you use it.

To see a similar issue, check image on iOS status bar orientation after play video fullscreen

Était-ce utile?

La solution

Ok, I figured it out.

I added a button to the view controller that I present as a modal view with my video and that button triggers the following:

[[UIApplication sharedApplication] setStatusBarOrientation:UIDeviceOrientationPortrait animated:NO];
[[UIApplication sharedApplication] setStatusBarHidden:NO];
[self dismissModalViewControllerAnimated:YES];

When the button is triggered, the status bar is forced to portrait and the app returns to normal state. I removed the action for the "Done" button when I'm in fullscreen.

Hope this helps someone

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top