Portrait and Landscape support iOS

I know that there are other posts about this topic on this forum but none of them work for me.

Problem: My app needs to support portrait and landscape. I added a applicationScreenSizeChanged in AppDelegate and it works fine in Android. However, in iOS, I get a black bar on one side, with the actual scene getting compressed in one direction and stretched in the other. Therefore, I am wondering what’s the proper way to support portrait and landscape modes for iOS.


I’ve never had a need for game to support both, so I would think that you would also need to work with RootViewController also. Perhaps some threads at Apple might help: https://developer.apple.com/forums/thread/115769

I thought that it might be something to do with RootViewController as well but I’m not sure what. One thing that I did notice is that although the scene is displaying incorrectly the underlying coordinates are still correct. i.e Pressing a button at the location that it’s supposed to be in will trigger it whereas trying to press the button where it is displaying on the screen will not do anything.

There are threads on full screen for MacOS, IIRC and those had a solution that worked. Perhaps there is a hidden gem in these threads.

@xxYxx Did you try this?

@smitpatel88 That’s basically what I’m doing right now. It works fine on Android but stretches weirdly on iOS.

I think it’ll be easier to explain with some images.

This is what it looks like when I launch my app in portrait mode.

It has a 4x3 grid of buttons. When I rotate my screen, I want to show a 3x4 grid of buttons. However, the following image is what I get instead.

I do get a 3x4 grid but the app isn’t displaying properly. If I don’t change the frame size and design resolution, I get the following instead.

That’s the original portrait mode but just rotated and stretched to fill the screen size (which what I assume iOS defaults to).

I think the problem may be due to some disparity between cocos2d-x changing frame size and iOS automatically changing frame size.

1 Like