在RN中如何调用本地iOS viewController'代码?
就像使用RN推送到本机iOS viewController,然后让本机代码完成任务一样。
您需要使用Export Method。
AppDelegate.h
#import <UIKit/UIKit.h>
#import "RCTBridgeModule.h"
@interface AppDelegate : UIResponder <UIApplicationDelegate,RCTBridgeModule>
@property (nonatomic, strong) UIWindow *window;
@end
AppDelegate.m
@implementation AppDelegate
RCT_EXPORT_MODULE()
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
//NO Change Here
}
RCT_EXPORT_METHOD(pushVC:(NSString *)vcName){
Class ctrlClass = NSClassFromString(vcName);
UIViewController *newVc = [[ctrlClass alloc] initWithNibName: vcName bundle: nil];
[[UIApplication sharedApplication].delegate.window.rootViewController presentViewController:newVc animated:YES completion:nil];
}
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句