Drawing a Component insiede a UIView

Hi everybody!
I’m trying to draw a component inside a UIView, but I can’t find the right method!

Can someone please help me :slight_smile:

now I’m using Component->getWindowHandle() to get the pointer to the UIView of the Component, but if I try to set the viewController’ view anything happens.
My code now is something like this

UIView* myView = (UIView*)myComponent->getWindowHandle();
[self setView:myView];

I think you need to look at the UIViewComponent class!

…oh no, sorry, just re-read your post, and that’s the opposite of what you want.

In fact, you’d want to pass the parent’s UIView* as the handle to the Component::addToDesktop method.

Exactly, I can get the parent *UIView, but I cannot assign it to the ios ViewController of XIb

I think as Jules said you need to use the addToDesktop method to make the component actually draw into the UIView. You might also need to call setVisible and make sure it has a size. I use a function which looks like this to do exactly what you’re asking:

static void addComponentToUIView (Component& comp, UIView* uiView) { comp.addToDesktop (0, (void*) uiView); comp.setVisible (true); comp.setBounds (uiView.bounds.origin.x, uiView.bounds.origin.y, uiView.bounds.size.width, uiView.bounds.size.height); }

Thanks guys!
I’ve just seen this other post

it works perfectly! :slight_smile: