'Using UIControllerView with react native bridging
I wanted to create a bridge between React-Native and iOS native( Swift/Objective-c ) code with the help of react-native's NativeModules & requireNativeComponent.
I am a newbie in iOS app development. I want to use UIViewController(from UIKit) for designing app screen in iOS. like this
import UIKit
class SignIn: UIViewController {
var meetingName: UILabel!
var meetingID: UILabel!
var meetingNameField: UITextField!
var meetingIDField: UITextField!
var launchMeet = [UIButton]()
override func loadView() {
view = UIView()
view.backgroundColor = .magenta
}
override func viewDidLoad() {
super.viewDidLoad()
view = UIView()
view.backgroundColor = .magenta
}
}
and going to register this code through a another class with RCTViewManager like this
import Foundation
import UIKit
@objc(SigninController)
class SigninController: RCTViewManager {
func view() -> UIViewController {
return SignIn()
}
override static func requiresMainQueueSetup() -> Bool {
return true
}
}
the above code will be bridge with macros provided from react native like this
#import "React/RCTViewManager.h"
@interface RCT_EXTERN_MODULE(SigninController, RCTViewManager)
@end
unfortunately i am not able to make it work.
But if i use UIView as per the William Dawson provided in this tutorial it's working.
I have searched a lot through web but there is no proper way available to extract this out of native code.
What i want :
- How do i create a ui programatically in iOS and use it in react-native through bridges they have provided.
- How do i trigger events from react-native and iOS native side.
The scenario i am working on for understanding purposes: create some login page in native iOS side and use it in react-native.
Please help!
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
