Reputation: 9536
I have a MPMoviePlayerController view added as a subview on my ViewController.
I am using layoutSubviews to resize subviews during orientation changes.
When I play the movie in fullscreen, and, while still in fullscreen, rotate the phone, sometimes when I exit full screen, my navigation Bar "hides" halfway below the status bar, as if the origins for both are the same with the status bar on top.
I'm wondering if I'm doing something wrong... can anyone help?
Thanks!
Upvotes: 3
Views: 3231
Reputation: 4919
Don't change your navigationBar's frame read bellow from Apple's docs:
The navigation controller manages the creation, configuration, and display of the navigation bar and optional navigation toolbar. It is permissible to customize the navigation bar’s appearance-related properties but you must never change its frame, bounds, or alpha values directly. If you subclass UINavigationBar, you must initialize your navigation controller using the initWithNavigationBarClass:toolbarClass: method. To hide or show the navigation bar, use the navigationBarHidden property or setNavigationBarHidden:animated: method
Now I do this and it works perfectly:
1) in entrance point in your view controller add your self as observer to the movies player states
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(playerChangedState) name:@"UIMoviePlayerControllerWillExitFullscreenNotification" object:nil];
2) Responding to the notification:
// run this method on the main thread
[[UIApplication sharedApplication] setStatusBarStyle:UIStatusBarStyleDefault];
[self.navigationController setNavigationBarHidden:YES];
[self.navigationController setNavigationBarHidden:NO animated:YES];
Note: This code works on iOS 7, I haven't tested it for older versions of iOS.
Upvotes: 6
Reputation: 9536
For anyone looking for an answer, I fixed it by resetting the navigationController.navigationBar frame's origin to 0,20 as follows:
self.navigationController.navigationBar.frame = CGRectMake(0, 20, self.navigationController.navigationBar.frame.size.width, self.navigationController.navigationBar.frame.size.height);
Upvotes: 3
Reputation: 2109
I had a similar problem and the accepted solution didn't help me - what did help was the answer to this post: Disappearing status bar at the top after MPMoviePlayerController is closed
Basically had to add a delayed call to set [UIApplication sharedApplication].statusBarHidden = NO;
(posted here just incase someone else has this issue)
Upvotes: 2