I am trying to add a UIViewcontroller to a SpriteBuilder project so that I can display other UI items, but I am having trouble adding it to the main scene.
I create the view controller, but all I can find to add it is:
[[CCDirector sharedDirector] presentViewController:viewController animated:YES completion:nil];
When I try this, Xcode tries to split the line up as it thinks it's 2 lines of code. I guess this is the Obj-C version? can anyone help with the Swift version?
Eventually I want to add a UIMediaPicker to this view controller. Is this the best way to go about it, or can I add the media picker directly to the COCO2D scene with the need for a view controller?
Thanks for all your help.
cocos2d renders itself in its own view controller. For Swift, the syntax for accessing this view controller would be:
let view = CCDirector.sharedDirector().parentViewController!.view
// Returns a UIView of the cocos2d parent view controller.
You can then use the view.addSubview(UIView view)
method to add subviews to the view controller.