views:

1214

answers:

1

When I try to use UIView with cocos2d I have a problem. I create UIViewController, add view to it and add view to window:

helpController=[[HelpController alloc] init];
helpController.view=view;
[[[[Director sharedDirector] openGLView] window] addSubview: helpController.view];

@interface HelpController : UIViewController
{
}
@end
@implementation HelpController
-(BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation {
 return  YES;
}
@end

This is function that remove view from window and run other cocos scene:

-(void)back:(id)sender {
 FadeTransition *tran=[FadeTransition transitionWithDuration:0.5f scene:[MainMenuScene node]];
 [helpController.view removeFromSuperview];
 [[Director sharedDirector] replaceScene:tran];

}

First time: http://tinyurl.com/nu98ub

The screen orientation is UIInterfaceOrientationLandscapeRight. First time then I run scene with this view, this view orientation is Landscape, but next times is Portrait, I can't resolve this problem. Somebody help me, please :)

+1  A: 

This URL http://www.cocos2d-iphone.org/wiki/doku.php/tips:cocos2d_and_uikitlayer Contains a class which addresses just your problem. Not exactly a timely answer, but hopefully that helps

Kenny Winker