In my application by default status bar is visible. And my app supports landscape as well as portrait orientations. When I want to play the video, i'm hiding the status bar, so that my video will be shown full screen. And when video completes, i'm bringing the status bar back.
I'm using following code to show the video:
UIWindow* window = [[UIApplication sharedApplication] keyWindow];
[window addSubview:playerView];
(I can't use view controllers in my code. That's a restriction)
Now the problem: My app is in landscape now, on click of a button, i'll hide the status bar and starts playing video. When video is playing, i change the orientation of the phone to portrait and I allowed video to complete. When video completed, the device is still in portrait mode, player view is removed and status bar is shown again. Now I noticed that my portrait view is moved 20 pixels up and over that the status bar is showing. But when I started the app for firs time, status bar is shown first and below it, my view is shown.
How should I handle this situation?
In simple use the following code in a view controller.
- (void)viewDidLoad {
[[UIApplication sharedApplication] setStatusBarHidden:YES];
[self performSelector:@selector(showStatusAgain) withObject:nil afterDelay:6.0];
[super viewDidLoad];
}
-(void)showStatusAgain
{
[[UIApplication sharedApplication] setStatusBarHidden:NO];
}
// Override to allow orientations other than the default portrait orientation.
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
return YES;
}
when u run the app with above code, it will start in portrait. now rotate it to landscape. and you can notice the issue.