Contain UIViewController in UIView

Viewed 1063

When developing React Native native UI components, RCTViewManager expects you to define a view method which returns a UIView. Here's a basic example of what I have setup at the moment, this just renders a small grey square on the screen:

@implementation RNThingComponent

- (void)drawRect:(CGRect)rect
{
    [[UIColor grayColor] setFill];

    CGContextFillRect(UIGraphicsGetCurrentContext(), rect);
}

@end


@implementation RNThingtManager

RCT_EXPORT_MODULE()

- (UIView *)view
{
    RNThingtComponent * view;

    view = [[RNThingtComponent alloc] init];

    return view;
}

@end

I have built quite a few native components like this, however I'm now working on a component which expects me to setup a UIViewController in order to render it's views.

Is it possible to wrap this UIViewController in a UIView so that I can return the view to React Native or will I have to somehow get the UIViewController to work with it?

0 Answers
Related