0
votes

I'm trying to link a Mapbox example class to my IOS app. The example class implemented viewDidLoad method, so I assume I should instantiate this code inside a UIViewController file right?

But unfortunately I don't have that file. I'm using react native and I assume I should have at least AppDelegate and UIViewController files correct? But I don't have it. I only have the UIViewController instantiated in AppDelegate.m like so:

UIViewController *rootViewController = [UIViewController new];

rootViewController.view = rootView;
self.window.rootViewController = rootViewController;

Is this the place where I should "link" the example class so that the viewDidLoad will be triggered?

1

1 Answers

2
votes

In order to implement the viewDidLoad method you must create a subclass of UIViewController. In the AppDelegate.m file you are using a parent class, not a subclass.

Once you've created the UIViewController subclass (you could name it something like MapboxViewController) you would substitute it for the first line of code listed.

Instead of

UIViewController *rootViewController = [UIViewController new];

you'd have

MapboxViewController *rootViewController = [MapboxViewController new];

Here is a Stack Overflow that explains how to add a view controller in a ReactNative project. It's in Swift, but I think is still a good guide.

React-Native iOS - How can I navigate to a non-React-Native view (native iOS view controller) from a React-Native view with a button press?