我有一个现有的应用程序,我正在努力为其中的一部分集成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];
}
Run Code Online (Sandbox Code Playgroud)
我最初的反应意见如下:
render() {
return (
<Navigator
style={styles.container}
...
Run Code Online (Sandbox Code Playgroud)
我在导航器上有一个右导航按钮,我想"关闭"反应视图和底层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];
} …Run Code Online (Sandbox Code Playgroud) 我试图理解为什么这段代码在Ruby 1.9.2中不起作用我也试图弄清楚它应该如何改变以使其工作.这是片段:
ruby-1.9.2-p290 :009 > str = "hello world!"
=> "hello world!"
ruby-1.9.2-p290 :010 > str.gsub("\223","")
RegexpError: invalid multibyte character: /?/
from (irb):10:in `gsub'
Run Code Online (Sandbox Code Playgroud)