Try to do something like this.
When you are pushing cocos scene on a uiviewcontroller then add this code in ViewDidLoad method.
-(void)viewDidLoad{
[super viewDidLoad];
CCDirector *director = [CCDirector sharedDirector];
if([director isViewLoaded] == NO)
{
CCGLView *glView = [CCGLView viewWithFrame:[[[UIApplication sharedApplication] keyWindow] bounds]
pixelFormat:kEAGLColorFormatRGB565
depthFormat:0
preserveBackbuffer:NO
sharegroup:nil
multiSampling:NO
numberOfSamples:0];
director.view = glView;
[director setAnimationInterval:1.0f/60.0f];
[director enableRetinaDisplay:YES];
}
director.delegate = self;
[self addChildViewController:director];
[self.view addSubview:director.view];
[director didMoveToParentViewController:self];
if(director.runningScene)
{
[director replaceScene:[SceneFirst scene]];
}
else
{
[director runWithScene:[SceneFirst scene]];
}
}
Here SceneFirst is your cocos Scene you want to push.Just add CCDirectorDelegate in your UiViewController as delegate.
and add this line of code in your ViewDidUnload method
[[CCDirector sharedDirector] setDelegate:nil];
For popping back to your Uikit view call this code on any CCmenu tapped
[[CCDirector sharedDirector] stopAnimation];
AppDelegate *app = (AppDelegate *)[[UIApplication sharedApplication] delegate];
[app.navigationController popViewControllerAnimated:YES];
Hope This Help!!:)