My video (AVPlayer instance) plays in a smaller "minimized" window to start. Touch the screen to show the controls, and allow the user to expand it to full screen, which covers the status bar. I'm giving the viewController this for its full frame:
[[UIScreen mainScreen] bounds]
But the viewController still thinks the status bar is there, even if I hide it first:
[[UIApplication sharedApplication] setStatusBarHidden:YES withAnimation:UIStatusBarAnimationSlide]
So the video screen starts below the unseen status bar, at (0, statusBarHeight). If I rotate the device with the controls visible (which makes the status bar visible), the problem remains. If I rotate the device when controls are hidden (and the status bar is missing), everything corrects itself, and the video window starts at (0,0) as expected.
My solution has been to start the full screen video window at (0, -statusBarHeight), then watch for a rotation with no controls, when I can then put the video window back to origin. Yuck.
When I minimize the video back to the original size, if there has been a rotation with no controls, the video window will be too high by (statusBarHeight) pixels.
So another boolean to tell me, when I minimize the video, if I should correct it's "real" position by (0, +statusBarHeight). Double yuck.
If, at this point, we rotate the device, everything is good. But if we instead maximize the video right away, then the full screen video is too high by (statusBarHeight) pixels. Triple yuck!
Okay, more booleans, but this is all complicated by the fact that the video engine is a separate framework, and the 'controlling app' also has similar problems.. AAH!
Am I going about this in the wrong way? It's just getting all too complicated and fragile. I know (by looking at other apps out in the wild) that this is a common problem - I have a list of apps that exhibit the same behaviour. Is there a better way?