Search code examples
iosxcodecocos2d-x

How to display portrait mode in cocos2d-x 2.2.3


I am developing a game in xcode using cocos2d-x 2.2.3. I want to change the mode from landscape to portrait. I used the following code in rootviewcontroller.mm file. But still its not working. Please anyone can help me. Thanks

return UIInterfaceOrientationIsPortrait( interfaceOrientation );

Solution

  • In your Rootviewcontroller.mm class change the code as following.

    - (void)didFinishBannerViewActionNotification:(NSNotification *)notification
    {
    NSLog(@"didFinishBannerViewActionNotification");
    }
    - (BOOL)shouldAutorotateToInterfaceOrientation:   (UIInterfaceOrientation)interfaceOrientation {
    return UIInterfaceOrientationIsPortrait( interfaceOrientation );
    }
    
    - (NSUInteger) supportedInterfaceOrientations{
    #ifdef __IPHONE_6_0
    return UIInterfaceOrientationMaskPortrait;
    #endif
    } 
    

    and in the xcode click your project name and in the general category change the Device orientation to portrait. I hope it will work.