Reputation: 312
I am trying to build a react native app in which I would like to embed a native view, could anyone tell me how to do this using a detailed example, i checked the guides but couldn't really follow.
I am currently using a viewController class to display the view in the native iOS app, I would like to display the same view using my react native app. Do I need to use a UIView class or can I also use a view controller class? If yes, how can I do it?
Please help, thanks in advance
Upvotes: 1
Views: 4028
Reputation: 1259
Check out this answer https://stackoverflow.com/a/68933743/6489702
In short; you load the View
of the UIViewController
as a subview to your native module but the Controller
of the UIViewController
you load as a child to the KeyWindow
UIViewController
that way you can use a native UIViewController
but still have your native view live in the life cycle and size of the native view module.
Upvotes: 0
Reputation: 20047
Details of embedding native views are very clearly explained (including example MapView) in the react-native documentation: http://facebook.github.io/react-native/docs/native-components-ios.html#content
Upvotes: 2