0

I want to use Kudan inside an existing React-Native App. You can create your own Native Components in React-Native so I thought I could make a Kudan-component.

In React-Native I have to write a function which returns a UIView, RN can place on the screen. But all tutorials about Kudan tell me to make my UIViewController into an ARCameraViewController which I can't do because of all the other RN-Components.

I tried the following (YTARViewController extends ARCameraViewController):

- (UIView *)view
{
  UIViewController* controller = [[YTARViewController alloc] init];
  UIView* view = [[ARCameraView alloc] init];
  controller.view = view;
  return view;
}

But this renders my app unresponsive with 100% CPU usage as soon as I instantiate this component from JS, which will run above code and try to place the view on screen, which doesn't happen, because the app is already unresponsive at this point.

  • I found a first solution by now. The problem was that I put the controller into a local variable, so I lost any reference to it, when the function terminated and it was garbage collected. When I keep a reference to the controller, the Camera shows up inside React Native. – Abraham Przewodnik Nov 30 '16 at 09:30

1 Answers1

0

Try this:

- (UIView *)view
{
  UIViewController* controller = [[YTARViewController alloc] init];
  UIView* view = [[ARCameraView alloc] init];
  [controller.view addSubview: view];
 \\ view.frame = assign frame here.
  return view;
}
PlusInfosys
  • 3,416
  • 1
  • 19
  • 33