0
votes

im having a problem with the landscape rotation while im working with cocos2d and cocosbuilder.

I have iPhone Landscape and iPhone5 Landscape on my cocosbuilder project And on the xcode Suported Interface Orientations i only have the landscape selected.

on my appDelegate.m i have:

-(NSUInteger)supportedInterfaceOrientations {

    return UIInterfaceOrientationMaskLandscape;
}

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
    return UIInterfaceOrientationIsLandscape(interfaceOrientation);
}

this should be really simple, but im having a hard time here, and really don't want to re-assemble my game again without using cocosbuilder

1
what version of ios you are using?nsgulliver
I'm using the latest version of both ios / xcode and cocosRicardo Cerqueira

1 Answers

1
votes

If you are supporting latest versions of iOS which is mostly used these days, then you should use these methods to check for orientation

- (UIInterfaceOrientation)preferredInterfaceOrientationForPresentation
{
    return UIInterfaceOrientationLandscapeLeft;
}


-(NSUInteger)supportedInterfaceOrientations

{
       return UIInterfaceOrientationMaskLandscape;
}


-(BOOL)shouldAutorotate {


        return YES;    
}

shouldAutorotateToInterfaceOrientation is deprecated in iOS6 and instead of using this method use the above methods which I have provided and read the UIViewController docs provided by apple there it is clearly written which methods you could use and for what purpose. here are some of the methods which you might use

willRotateToInterfaceOrientation:duration: 
willAnimateRotationToInterfaceOrientation:duration:
and didRotateFromInterfaceOrientation: