内容简介:翻译自:https://stackoverflow.com/questions/35298144/react-native-dismiss-exit-react-native-view-back-to-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}
...
我在导航器上有一个右导航按钮,我想“解除”反应视图和底层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];
}
任何有关“退出”反应本机视图并返回本机视图的方法的帮助将不胜感激.
它的要点是:
>在Obj-C中创建一个NotificationManager类并将其公开为React Module
>在ViewController寄存器中获取接收触发时的通知[self dismissViewController ..]
翻译自:https://stackoverflow.com/questions/35298144/react-native-dismiss-exit-react-native-view-back-to-native
以上所述就是小编给大家介绍的《ios – React-Native:关闭/退出React-Native View返回Native》,希望对大家有所帮助,如果大家有任何疑问请给我留言,小编会及时回复大家的。在此也非常感谢大家对 码农网 的支持!
本站部分资源来源于网络,本站转载出于传递更多信息之目的,版权归原作者或者来源机构所有,如转载稿涉及版权问题,请联系我们。
Approximation Algorithms
Vijay V. Vazirani / Springer / 2001-07-02 / USD 54.95
'This book covers the dominant theoretical approaches to the approximate solution of hard combinatorial optimization and enumeration problems. It contains elegant combinatorial theory, useful and inte......一起来看看 《Approximation Algorithms》 这本书的介绍吧!