Cocos2d vs UIKit

When I try to use UIView with cocos2d, I have a problem. I create a UIViewController, add a view to it and add a view to the 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 a function that removes the view from the window and launches another coconut 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

Screen Orientation - UIInterfaceOrientationLandscapeRight. The first time I start a scene with this view, this orientation looks like Landscape, but the next time it is Portrait, I can not solve this problem. Someone help me please :)

+3
source share

Source: https://habr.com/ru/post/1718084/


All Articles