I am streaming a movie on the iPad using MPMoviePlayerController
.
When the user rotates the device to landscape, I animate it to fullscreen.
If the user then taps 'exit fullscreen' or 'done', the movie animates back to its small frame (native behavior), BUT-- the top bar (navigation bar) is gone. Also, the visible views have moved upwards, behind and beyond the status bar.
Note that I haven't touched the top bar whatsoever. I have not manually hidden it.
I have tried regaining the navigation bar by sending setNavigationBarHidden:animated
to the current viewcontroller's navigation controller, as well as to the tabbarcontroller's navigationcontroller. I put this in response to the MPMoviePlayerDidExitFullscreenNotification
(it fires). No effect. If we rotate back to portrait, however, it's back instantly.
My questions are:
- Why does the top bar not return when full screen is exited by the user?
- How can we get the top bar back?
Best regards, Timo
P.S. I will proceed to experiment with the weirdnesses described in this SO post. Might be related.
The first assumption may be that the problem is with
[MPMoviePlayerControler setFullScreen]
and the same was mine. But after looking more carefully I came to know that the problem was with controls provided withMPMoviePlayerController
(Play,Pause,Done etc.) by Apple. The mode of controls is set to Default controls by Apple. When we rotate the device the controls should be changed according to the new dimensions of the screen which doesn't happen. So, we should refresh the controls while rotating the device.Following is the code which did the same for me:
This will do the task perfectly. At least it did it for me.
Since this appears to be a bug in Apple's SDK (read post scriptum below), I have worked around it.
When you get the
MPMoviePlayerDidExitFullscreenNotification
, take the following steps:[setNavigationBarHidden:YES animated:NO]
to the navigation bar.[setNavigationBarHidden:NO animated:YES]
to the navigation bar.There will be a slight glitch, namely the bar animating back down. Still, it's a lot better than your bar disappearing and the user left in wonder!
The
animated:YES
seems necessary to make the bar (re)set its position (rather than just its visibility).You could try to make it appear instantly (
animated:NO
) after a 0 or 0.1 second delay using-performSelector:withObject:afterDelay:
. You will probably still have to start the animation first, or the bar won't adjust its position.Cheers, Timo
P.S. This appears to be a bug in the SDK. If you run, for example, the TED iPad application, you can reproduce it in there as well. The steps were something along the lines of: play a video, pinch to fullscreen, rotate iPad to landscape, press done. Experiment with it a bit and you should see the navigation bar disappear.
I just found a better way to to this (without the glitch when back from the view controller). Hiding the navigation bar when entering fullscreen and displaying it again on exit :
This will just be a bit more smooth in the animations.