这是我要尝试执行的操作,但出现错误。我已经将根导航设置为bottomTabs
(这类似于应用程序的主菜单),它具有两个子项:堆栈布局和组件布局。在堆栈屏幕上,我按一些其他屏幕(只是组件布局),在该组件布局上,我想按bottomTabs
布局推送新屏幕-这将是新的bottomTabs,以便通过“ {{ 1}}现在已隐藏,用户可以看到该新的bottomTabs菜单-仅用于该屏幕。我收到此错误:
Navigation.setRoot
如果我只是推送组件布局-一切都很好,那么问题肯定出在bottomTabs布局上。
这是我的代码:
index.js->设置导航根
Exception '-[RNNTabBarController isCustomTransitioned]: unrecognized selector sent to instance 0x7f82e2876600'
was thrown
while invoking push on target RNNBridgeModule with params(
push11,
Component6, {
children = ({
children = ();
data = {
name = "mad.app.Dummy";
options = {
bottomTab = {
text = tab1;
};
};
};
id = Component9;
type = Component;
}, {
children = ();
data = {
name = "mad.app.Smarty";
options = {
bottomTab = {
text = "Tab 2";
};
};
};
id = Component10;
type = Component;
});
data = {};
id = ee;
type = BottomTabs;
},
3324,
3325
)
callstack: (
0 CoreFoundation 0x000000010388c29b __exceptionPreprocess + 331
1 libobjc.A.dylib 0x0000000101f6f735 objc_exception_throw + 48
2 CoreFoundation 0x00000001038aafa4 -[NSObject(NSObject) doesNotRecognizeSelector:] + 132
3 UIKitCore 0x000000010849d163 -[UIResponder doesNotRecognizeSelector:] + 287
4 CoreFoundation 0x0000000103890fb6 ___forwarding___ + 1446
5 CoreFoundation 0x0000000103892e88 _CF_forwarding_prep_0 + 120
6 TestMobileApp 0x0000000100b567f8 -[RNNCommandsHandler push:layout:completion:rejection:] + 2840
7 TestMobileApp 0x0000000100b18a88 -[RNNBridgeModule push:componentId:layout:resolver:rejecter:] + 392
8 CoreFoundation 0x000000010389311c __invoking___ + 140
9 CoreFoundation 0x00000001038905b5 -[NSInvocation invoke] + 325
10 CoreFoundation 0x0000000103890a06 -[NSInvocation invokeWithTarget:] + 54
11 TestMobileApp 0x0000000100c1791a -[RCTModuleMethod invokeWithBridge:module:arguments:] + 2810
12 TestMobileApp 0x0000000100cd3646 _ZN8facebook5reactL11invokeInnerEP9RCTBridgeP13RCTModuleDatajRKN5folly7dynamicE + 790
13 TestMobileApp 0x0000000100cd315f _ZZN8facebook5react15RCTNativeModule6invokeEjON5folly7dynamicEiENK3$_0clEv + 127
14 TestMobileApp 0x0000000100cd30d9 ___ZN8facebook5react15RCTNativeModule6invokeEjON5folly7dynamicEi_block_invoke + 25
15 libdispatch.dylib 0x000000010697c51d _dispatch_call_block_and_release + 12
16 libdispatch.dylib 0x000000010697d587 _dispatch_client_callout + 8
17 libdispatch.dylib 0x00000001069893bc _dispatch_main_queue_callback_4CF + 1290
18 CoreFoundation 0x00000001037ef7f9 __CFRUNLOOP_IS_SERVICING_THE_MAIN_DISPATCH_QUEUE__ + 9
19 CoreFoundation 0x00000001037e9e86 __CFRunLoopRun + 2342
20 CoreFoundation 0x00000001037e9221 CFRunLoopRunSpecific + 625
21 GraphicsServices 0x000000010cd271dd GSEventRunModal + 62
22 UIKitCore 0x00000001080b6115 UIApplicationMain + 140
23 TestMobileApp 0x0000000100a79420 main + 112
24 libdyld.dylib 0x0000000104a64551 start + 1
)
第一个标签(mad.app.LogsScreen)具有将此布局压入堆栈的按钮:
Navigation.events().registerAppLaunchedListener(() => {
Navigation.setRoot({
root: {
bottomTabs: {
children: [
{
stack: {
children: [
{
component: {
name: "mad.app.LogsScreen",
options: {
topBar: {
visible: false,
drawBehind: true
}
}
}
}
],
options: {
bottomTab: {
text: "Tab 1",
testID: "tab1-btn"
}
}
}
},
{
component: {
name: "mad.app.Dummy",
options: {
bottomTab: {
text: "Tab 2",
testID: "tab2-btn"
}
}
}
}
]
}
}
});
});
在此推送的屏幕上,单击“完成”,我想使用新的bottomTabs推送布局,这是我尝试推送的布局:
const screenLayout = {
component: {
name: "mad.app.Creator.CreatorScreen",
options: {
topBar: {
rightButtons: [
{
text: "Done",
id: "mad.app.Creator.CreatorScreen.header.right.1"
}
]
},
}
}
};
export default screenLayout;
但是,如果我只是尝试按如下方式推送组件布局,则会收到上面提供的错误:
const screen = {
bottomTabs: {
id: "ee",
children: [
{
component: {
name: "mad.app.Dummy",
options: {
bottomTab: {
text: "tab1"
}
}
}
},
{
component: {
name: "mad.app.Smarty",
options: {
bottomTab: {
text: "Tab 2"
}
}
}
}
]
}
};
export default screen;
然后一切正常。是否可以实现我想要的?如果可以,怎么办?
谢谢!