2016-03-10 79 views

回答

2

您需要使用導出方法。

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]; 
    } 
+0

pushVC方法需要一個PARAM以指示哪些的viewController被推。 –

+0

@RainerLiao回答更新 – Rahul

+0

感謝您的留言。但是如何在React Native中調用這個方法? – rocLv