ネイティブ コードと React Native を混在させるプロジェクトがあります。React ビューを次のように表示します。
self.reactView = [[RCTRootView alloc] initWithBridge:bridge moduleName:@"DemoPage" initialProperties:initialProperties];
[self.view addSubview:self.reactView];
上記は機能し、ビューは正しく表示されます。ビューはアイテムのリストです。リスト項目が選択されると、View Controller に応答するはずであり、ネイティブの View Controller をプッシュします。私はこのようなネイティブモジュールでこれを行います:
RCT_EXPORT_MODULE(NavigationUtils);
RCT_EXPORT_METHOD(navigateWithParameters:(NSString *)parameters)
{
ViewController *viewController = [[ViewController alloc] initWithNibName:@"ViewController" bundle:nil];
[self.navigationController pushViewController:viewController animated:YES];
}
私の問題は、しようとするとpushViewController:
、プッシュが何もしないことです。self.navigationController
nil
presentViewController:
も機能しません。
self.navigationController
nil
viewWillAppear:
またはにないviewDidAppear:
React Native Module から新しいネイティブ ビュー コントローラーをプッシュする方法を知っている人はいますか?
ビュー階層の recursiveDescription を編集したものを次に示します。
<UIWindow: 0x102a10970; frame = (0 0; 414 736); autoresize = W+H; tintColor = UIExtendedSRGBColorSpace 0.313725 0.52549 0.764706 1; gestureRecognizers = <NSArray: 0x17405ab20>; layer = <UIWindowLayer: 0x17422ae20>>
| <UIView: 0x102b55ff0; frame = (0 0; 414 736); autoresize = W+H; gestureRecognizers = <NSArray: 0x17064e550>; layer = <CALayer: 0x170631220>>
| | <UIView: 0x102b6b580; frame = (0 0; 414 736); autoresize = W+H; layer = <CALayer: 0x170631260>>
| | | <UILayoutContainerView: 0x102b689d0; frame = (0 0; 314 736); hidden = YES; autoresize = RM+H; gestureRecognizers = <NSArray: 0x17064d410>; layer = <CALayer: 0x17062f4e0>>
| | | | <UINavigationTransitionView: 0x102b6ab20; frame = (0 0; 314 736); clipsToBounds = YES; autoresize = W+H; layer = <CALayer: 0x170631100>>
| | | | | <UIViewControllerWrapperView: 0x102b74ad0; frame = (0 0; 314 736); autoresize = W+H; layer = <CALayer: 0x1706350c0>>
| | | | | | <UITableView: 0x10388f400; frame = (0 0; 314 736); clipsToBounds = YES; autoresize = W+H; gestureRecognizers = <NSArray: 0x1748569e0>; layer = <CALayer: 0x17482a600>; contentOffset: {0, 0}; contentSize: {314, 630}>
| | | | | | | ...Cells and seperators
| | | | <UINavigationBar: 0x102b68b90; frame = (0 20; 314 44); opaque = NO; autoresize = W; gestureRecognizers = <NSArray: 0x17064db00>; layer = <CALayer: 0x170630c60>>
| | | | | <_UIBarBackground: 0x102b68e40; frame = (0 -20; 314 64); userInteractionEnabled = NO; layer = <CALayer: 0x170630ce0>>
| | | | | | <UIImageView: 0x102b69450; frame = (0 64; 314 0.333333); userInteractionEnabled = NO; layer = <CALayer: 0x170630d20>> - (null)
| | | | | | <UIVisualEffectView: 0x102b69640; frame = (0 0; 314 64); layer = <CALayer: 0x170630d40>>
| | | | | | | <_UIVisualEffectBackdropView: 0x102b69a80; frame = (0 0; 314 64); autoresize = W+H; userInteractionEnabled = NO; layer = <UICABackdropLayer: 0x170630da0>>
| | | | | | | <_UIVisualEffectFilterView: 0x102b6a380; frame = (0 0; 314 64); autoresize = W+H; userInteractionEnabled = NO; layer = <CALayer: 0x170630f60>>
| | | | | | | <_UIVisualEffectFilterView: 0x102a850b0; frame = (0 0; 314 64); alpha = 0.85; autoresize = W+H; userInteractionEnabled = NO; layer = <CALayer: 0x17482c3e0>>
| | | | | <UIImageView: 0x102a7e940; frame = (89 3.33333; 136 37.6667); opaque = NO; userInteractionEnabled = NO; layer = <CALayer: 0x174829240>> - (null)
| | | | | <_UINavigationBarBackIndicatorView: 0x102b6a730; frame = (12 11.6667; 13 21); alpha = 0; opaque = NO; userInteractionEnabled = NO; layer = <CALayer: 0x170631000>> - Back
| | | <MMDrawerCenterContainerView: 0x102b6b8d0; frame = (0 0; 414 736); autoresize = W+H; layer = <CALayer: 0x1706312c0>>
| | | | <UILayoutContainerView: 0x102aafb40; frame = (0 0; 414 736); autoresize = W+H; gestureRecognizers = <NSArray: 0x170441890>; layer = <CALayer: 0x17422ad60>>
| | | | | <UINavigationTransitionView: 0x102ab02e0; frame = (0 0; 414 736); clipsToBounds = YES; autoresize = W+H; layer = <CALayer: 0x17422adc0>>
| | | | | | <UIViewControllerWrapperView: 0x102a828b0; frame = (0 0; 414 736); autoresize = W+H; layer = <CALayer: 0x174a201a0>>
| | | | | | | <UIView: 0x102b98e20; frame = (0 0; 414 736); autoresize = W+H; layer = <CALayer: 0x170c209a0>>
| | | | | | | | <RCTRootView: 0x102b9a8d0; frame = (0 64; 414 736); autoresize = W+H; layer = <CALayer: 0x170c221c0>>
| | | | | | | | | ...subviews of RCTRootView
| | | | | <UINavigationBar: 0x102aaf160; frame = (0 20; 414 44); opaque = NO; autoresize = W; gestureRecognizers = <NSArray: 0x174258690>; layer = <CALayer: 0x17422a720>>
| | | | | | <_UIBarBackground: 0x102aaf410; frame = (0 -20; 414 64); userInteractionEnabled = NO; layer = <CALayer: 0x17422ab40>>
| | | | | | | <UIImageView: 0x102a9e1e0; frame = (0 64; 414 0.333333); userInteractionEnabled = NO; layer = <CALayer: 0x17422a9c0>> - (null)
| | | | | | | <UIVisualEffectView: 0x102a9e3d0; frame = (0 0; 414 64); layer = <CALayer: 0x174230c60>>
| | | | | | | | <_UIVisualEffectBackdropView: 0x102a98840; frame = (0 0; 414 64); autoresize = W+H; userInteractionEnabled = NO; layer = <UICABackdropLayer: 0x1742327c0>>
| | | | | | | | <_UIVisualEffectFilterView: 0x102a98ba0; frame = (0 0; 414 64); autoresize = W+H; userInteractionEnabled = NO; layer = <CALayer: 0x174233560>>
| | | | | | | | <_UIVisualEffectFilterView: 0x102ab1380; frame = (0 0; 414 64); alpha = 0.85; autoresize = W+H; userInteractionEnabled = NO; layer = <CALayer: 0x174233660>>
| | | | | | <<UINavigationItemView: 0x102ab04c0; frame = (169.333 8; 75.3333 27); opaque = NO; userInteractionEnabled = NO; layer = <CALayer: 0x174422a80>>: item=<<UINavigationItem: 0x1703c6900>: title:'Accounts'> title=Accounts>
| | | | | | | <UILabel: 0x102b1a660; frame = (0 3; 75.3333 21.3333); text = 'Accounts'; opaque = NO; userInteractionEnabled = NO; layer = <_UILabelLayer: 0x17488cda0>>
| | | | | | <UINavigationButton: 0x102a80b40; frame = (9 6; 48 30); opaque = NO; tintColor = UIExtendedSRGBColorSpace 0.313725 0.52549 0.764706 1; layer = <CALayer: 0x174830340>>
| | | | | | | <UIImageView: 0x102b66cd0; frame = (11 2; 26 26); clipsToBounds = YES; opaque = NO; userInteractionEnabled = NO; layer = <CALayer: 0x170c20bc0>> - (null)
| | | | | | <_UINavigationBarBackIndicatorView: 0x102ab00f0; frame = (12 11.6667; 13 21); alpha = 0; opaque = NO; userInteractionEnabled = NO; layer = <CALayer: 0x17422ad20>> - Back