0

The app is set up for only landscape.

In Project->target->Summary->Supported Interface Orientations, I enabled the 2 landscape icons (both left and right).

And in AppDelegate.m, the below code is written:

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

When the app is running on the device, the view showed at the beginning after the default cocos2d icon, all the positions are wrong which were all moved to the right-down side. When I rotate the screen, everything goes right, all in right position.

What's wrong?

I also tried the method below: I disable all the icons in In Project->target->Summary->Supported Interface Orientations. The code in AppDelegate still in use. Then the view at the very beginning is ok but the screen can be rotated to protrait.

....

Any one can help?

Guru
  • 21,652
  • 10
  • 63
  • 102
Stella
  • 1,197
  • 1
  • 10
  • 18

1 Answers1

1

Also put these two for iOS6 orientation, in AppDelegate.

-(NSUInteger)supportedInterfaceOrientations {

    return UIInterfaceOrientationMaskLandscape;
}

- (NSUInteger)application:(UIApplication*)application supportedInterfaceOrientationsForWindow:(UIWindow*)window
{
    return UIInterfaceOrientationMaskLandscape;
}

Look at this question and answer once.

Community
  • 1
  • 1
Guru
  • 21,652
  • 10
  • 63
  • 102
  • Thank you for your answer.I tried to add these two methods. The portrait is gone. But the view first loaded is missing the right part, only show the left 2/3 part. The positons of the view is ok. There is still something missing or wrong. – Stella Apr 09 '13 at 04:04
  • After reading the answer above, I tried to put the init functions into the onEnter method of the first View. From the log, I can see the onEnter is fired after init, but the problem still exists. – Stella Apr 09 '13 at 05:35
  • manually added any new view? post your code in application didFinishLaunchingWithOptions – Guru Apr 09 '13 at 08:08
  • in didFinishLaunchingWithOptions:[SceneManager goMenu]; And in SceneManager.m : +(void)goMenu{ CCLayer *layer=[MenuLayer node]; [SceneManager go:layer]; } +(void)go:(CCLayer *)layer{ CCDirector *director=[CCDirector sharedDirector]; CCScene *newScene=[SceneManager wrap:layer]; if([director runningScene]){ [director replaceScene:newScene]; }else{ [director runWithScene:newScene]; } } – Stella Apr 09 '13 at 08:54