Part of Screen Goes Black when Rotating iOS Device

I am trying to support multiple orientations on iOS in cocos2d.x-2.2. When I rotate the device part of the screen goes black while the screen rotates. It looks like cocos is setting the view dimensions to a square before rotating.
So for example, if I hold the device in landscape and then rotate it to portrait it looks like this:

  • The top of the screen gets cut off (goes black)
  • The view rotates. It looks like a square the size of the smallest screen dimension.
  • The top of the screen re-appears and everything looks amazing again :slight_smile:

Everything in the bottom left is where it is supposed to be, so there is no offset problem like the previous poster mentioned. It seems like the GL View dimensions are being set before animating the rotation and the OS sets its dimensions _after_wards. So the OS disagreeing with cocos about the orientation of the devices result in a square view during the rotation.

What I am doing:
I am returning true in shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)orientation.

In my RootViewController I have added

@

  • (void)didRotateFromInterfaceOrientation:(UIInterfaceOrientation)fromInterfaceOrientation
    {
    CGSize s;
    if (UIInterfaceOrientationIsLandscape(UIApplication.sharedApplication.statusBarOrientation)) {
    s = CGSizeMake(std::max(UIScreen.mainScreen.bounds.size.width, UIScreen.mainScreen.bounds.size.height), std::min(UIScreen.mainScreen.bounds.size.width, UIScreen.mainScreen.bounds.size.height));
    } else {
    s = CGSizeMake(std::min(UIScreen.mainScreen.bounds.size.width, UIScreen.mainScreen.bounds.size.height), std::max(UIScreen.mainScreen.bounds.size.width, UIScreen.mainScreen.bounds.size.height));
    }
    if ([[UIScreen mainScreen] respondsToSelector:selector(scale)]) { // Retina s.width *= 2; s.height *= 2; } cocos2d::CCDirector* director = cocos2d::CCDirector::sharedDirector(); director->getOpenGLView()->setFrameSize(s.width, s.height); director->getOpenGLView()->setDesignResolutionSize(s.width, s.height, kResolutionShowAll); }

I noticed that when I put the above code in
RootController: - (void)orientationChanged:(NSNotification *)notification
I get the same black rectangle when I tilt the device forward. Dunno if that’s relevant, but does illustrate cocos and the OS disagreeing about device orientation again.
Cheers,
p