开发者

iPhone Game Landscape Orientation Issue

开发者 https://www.devze.com 2023-02-23 04:01 出处:网络
I am trying to make a simple iPhone game and I need the game to be in landscape mode.I can get the initial view to be landscape, but if remove the initial view and replace it with a new view (going fr

I am trying to make a simple iPhone game and I need the game to be in landscape mode. I can get the initial view to be landscape, but if remove the initial view and replace it with a new view (going from Main Menu to Game Screen) the new view is now in portrait mode. Also, if I switchback to the first view (removing the game screen and then creating the new menu view) the view is still in portrait mode. I have the Info.plist file set up correctly to initialize with landscape right and I have the GameViewController.m file set up with the following code:

-(BOOL) shouldAutorotateToInterfaceOrientation:
        (UIInterfaceOrientation)interfaceOrientation 
{
    return (interfaceOrientation == UII开发者_如何学运维nterfaceOrientationLandscapeRight);
}

I have read many postings about people having troubles with setting up the landscape orientation, but they always seem to be about the initial load of the app (only displaying one view). I can't seem to find any solutions for this problem. Can someone help me?


You have stumbled on to

one of the most famous bugs on the platform!

Congratulations for spotting it! Here:

iPhone app in landscape mode, 2008 systems

be sure to read the paragraph that begins: "An important reminder of the ADDITIONAL well-known problem at hand here......." !!

It gives you the solution, which is used in all apps.


Make sure that all the view controllers that are visible on screen support the landscape orientation. I would recommend, in your shouldAutorotateToInterfaceOrientation, to return UIInterfaceOrientationIsIsLandscape(interfaceOrientation); instead of your code. This will ensure that both landscape orientation will work. Can you share a bit more how you are switching from the main menu to the game screen?

0

精彩评论

暂无评论...
验证码 换一张
取 消