Overlaying a UIView onto a Cocos layer?

I’m new to iOS and Cocos development.

I currently have a basic app going on in my HelloWorldLayer class. It contains my sprites and touch interaction methods and all is well.

  • Feeding parsed data to RKMapperOperation throws NSUnknownKeyException
  • For Soap NSURLConnection, Please ensure that your app supports IPv6 networks, as IPv6 compatibility is required
  • Word wrap for NSMutableAttributedString
  • How to get a photo's original filename in iOS?
  • GCD: How to change timer fire interval
  • Is OpenGL threadsafe for multiple threads with distinct contexts?
  • I’m trying to add another “panel” (UIView?) over top of what is currently seen. Eventually this panel will have buttons or other things that will interact with the main canvas.

    How can I include another UIView onto the canvas screen? Through my appDelegate, or my HelloWorldLayer?

    Thanks

    Solutions Collect From Internet About “Overlaying a UIView onto a Cocos layer?”

    Here is one way to do it. I’ve used UITextView here but you could use the approach for any descendant of UIView. Bear in mind that UIKit’s y coordinate is zero at the top-left of the screen, whereas Cocos2D’s is zero at the bottom left.

    // Make your subview
    UITextView* t = [[UITextView alloc] initWithFrame: CGRectMake(10, 10, 200, 200)];
    t.backgroundColor = [UIColor blackColor];
    t.textColor = [UIColor whiteColor];
    t.text = @"Hello UIKit!";
    t.editable = NO;
    
    // Add it as a subview of the Cocos2D view
    UIView* cocosView = [[CCDirector sharedDirector] openGLView];
    [cocosView addSubview:t];
    

    Alternatively you could try Blue Ether’s CCUIViewWrapper, repository here.