反应本机调用iOS ViewController
在RN中如何调用本机iOS viewController的代码反应本机调用iOS ViewController,ios,react-native,Ios,React Native,在RN中如何调用本机iOS viewController的代码 就像使用RN推送到本机iOS viewController,然后让本机代码执行任务。您需要使用导出方法 AppDelegate.h #import <UIKit/UIKit.h> #import "RCTBridgeModule.h" @interface AppDelegate : UIResponder <UIApplicationDelegate,RCTBridgeModule> @property
就像使用RN推送到本机iOS viewController,然后让本机代码执行任务。您需要使用导出方法 AppDelegate.h
#import <UIKit/UIKit.h>
#import "RCTBridgeModule.h"
@interface AppDelegate : UIResponder <UIApplicationDelegate,RCTBridgeModule>
@property (nonatomic, strong) UIWindow *window;
@end
您可以在javascript中调用上述响应,如下所示:
import { NativeModules } from 'react-native'
NativeModules.AppDelegate.pushVC('viewControllerNameHere')
但我强烈建议使用外部文件制作桥接式文档,请在此处解释:
pushVC方法需要一个参数来指示要推哪个viewController。谢谢您的帖子。但是如何在React Native中调用此方法?
import { NativeModules } from 'react-native'
NativeModules.AppDelegate.pushVC('viewControllerNameHere')