【发布时间】:2016-05-19 19:09:02
【问题描述】:
我有一个现有的应用程序,我正在为它的一部分集成 React-Native。我是 无法理解如何“退出” react-native 并返回到原生视图。
这里有一些代码:
// Main objective-c code that bootstraps the react-native view. This view is loaded as a modal view.
MainViewController.m:
- (void)viewDidLoad {
[super viewDidLoad];
RCTRootView *rootView = [[RCTRootView alloc] initWithBundleURL:jsCodeLocation moduleName:@"IndexApp" initialProperties:props launchOptions:nil];
rootView.frame = CGRectMake(0, 0, self.view.bounds.size.width, self.view.bounds.size.height-49);
[self.view addSubview:rootView];
}
我最初的反应观点是这样的:
render() {
return (
<Navigator
style={styles.container}
...
我在 Navigator 上有一个右导航按钮,我想“关闭”反应视图和底层 MainViewController 本机视图。
我已经尝试像这样从反应视图回调 MainViewController,但没有成功:
RCT_EXPORT_METHOD(dismiss:(NSString *)name location:(NSString *)location)
{
NSLog(@"dismiss...");
// these don't do anything
//[self dismissViewControllerAnimated:YES completion:nil];
//[self.navigationController popViewControllerAnimated:YES];
// anything with _rootView doesn't do anything, i.e. _rootView removeFromSuperview];
}
任何有关“退出”反应原生视图并返回原生视图的方法的帮助将不胜感激。
【问题讨论】:
-
“我已经尝试回调 MainViewController”,你是怎么做到的?
标签: ios objective-c react-native