Quantcast
Channel: Active questions tagged react-native+ios - Stack Overflow
Viewing all articles
Browse latest Browse all 16750

How can I present a native UIViewController in React Native?

$
0
0

I am trying to use mpandroidchart's IOS version package in RN native IOS, This is how I tried to implement it.

ChartManager.m

#import "React/RCTViewManager.h"

@interface RCT_EXTERN_MODULE(RNTChartManager, RCTViewManager)

@end

ChartManager.swift

import Foundation
import UIKit
import React

@objc(RNTChartManager)
class RNTChartManager: RCTViewManager {
  override func view() -> UIView! {
    let label = UILabel()
    label.text = "Hello world"
    label.textAlignment = .center
    return label
  }
}

ChartViewController.swift

import Foundation
import UIKit
import Charts
import React

class BarChartViewController: UIViewController {

  @IBOutlet weak var barChartView: BarChartView!

    override func viewDidLoad() {
        super.viewDidLoad()
        barChartView.noDataText = "You need to provide data for the chart."
    }

}

AppName-Bridging-Header.h

#ifndef Investor_Bridging_Header_h
#define Investor_Bridging_Header_h
#import "React/RCTBridgeModule.h"
#import "React/RCTViewManager.h"
#import "React/RCTBundleURLProvider.h"

#endif

How would I do this in React Native? I can't write a bridged UI component since it's a UIViewController, not a UIView. Thanks in advance


Viewing all articles
Browse latest Browse all 16750

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>