在 UIView 中包含 UIViewController

edc*_*dcs 5 objective-c uiviewcontroller uiview ios react-native

在开发 React Native 原生 UI 组件时,RCTViewManager期望您定义一个view返回UIView. 这是我目前设置的一个基本示例,这只是在屏幕上呈现一个小的灰色方块:

@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
Run Code Online (Sandbox Code Playgroud)

我已经构建了很多这样的本机组件,但是我现在正在开发一个组件,它希望我设置 aUIViewController以呈现它的视图。

是否可以将它包装UIViewController在 a 中,UIView以便我可以将视图返回给 React Native,或者我必须以某种方式UIViewController使用它?