内容简介:翻译自: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》,希望对大家有所帮助,如果大家有任何疑问请给我留言,小编会及时回复大家的。在此也非常感谢大家对 码农网 的支持!
猜你喜欢:- 在退出时关闭文件描述符是一个很好的做法
- 头条天天见 | 苹果:滑动关闭程序缩短 iPhone 电池寿命,你经常滑动退出吗?巴菲特:已将孙宇晨赠予的加密货币交至慈善机构
- JVM安全退出
- SpringBoot优雅退出
- 一次 JVM 进程退出分析
- iOS 登录、退出流程整理
本站部分资源来源于网络,本站转载出于传递更多信息之目的,版权归原作者或者来源机构所有,如转载稿涉及版权问题,请联系我们。
Effective JavaScript
David Herman / Addison-Wesley Professional / 2012-12-6 / USD 39.99
"It's uncommon to have a programming language wonk who can speak in such comfortable and friendly language as David does. His walk through the syntax and semantics of JavaScript is both charming and h......一起来看看 《Effective JavaScript》 这本书的介绍吧!