Đây là một chiều sâu hơn nswer dựa trên this issue in React-Native
Trong thanh bên trái của Xcode, chọn 'Project Manger' (biểu tượng thư mục) để xem cấu trúc tệp.
Các thư mục cụ thể bạn đang tìm kiếm được tìm thấy tại địa chỉ: [YourAppName]> Thư viện> React.xcodeproj> Phản ứng> Lần
RCTNavItem.h
#import "RCTComponent.h"
@interface RCTNavItem : UIView
//add this line:
@property (nonatomic, assign) BOOL showTabBar;
RCTNavItemManager.m
@implementation RCTNavItemManager
RCT_EXPORT_MODULE()
- (UIView *)view
{
return [RCTNavItem new];
}
// add this line:
RCT_EXPORT_VIEW_PROPERTY(showTabBar, BOOL)
RCTNavigator.m
- (void)navigationController:(UINavigationController *)navigationController
willShowViewController:(__unused UIViewController *)viewController
animated:(__unused BOOL)animated
{
// Add these two lines:
RCTWrapperViewController *thisController = (RCTWrapperViewController *)viewController;
navigationController.tabBarController.tabBar.hidden = !thisController.navItem.showTabBar;
tôi không cần thêm propTypes để NavigatorIOS.ios.js hoặc TabBarIOS.ios.js
Để cho tất cả điều này để làm việc, mỗi tab dường như cần phải có thành phần NavigatorIOS riêng của mình.Khi tôi đã có tab chỉ đơn giản là trình bày một màn hình - (void) navigationController: (UINavigationController *) navigationController ... phương pháp không được gọi. Đây không phải là một vấn đề đối với tôi, bởi vì ẩn navBar dễ dàng thực hiện với navigationBarHidden: true.
Trong trường hợp của tôi, tôi đã có một TabNav> HomeNav> Homescreen
Passing showTabBar chống đỡ trong HomeNav:
render() {
return (
<NavigatorIOS
style={styles.container}
client={this.props.client}
initialRoute={{
title: 'Home',
component: HomeScreen,
navigationBarHidden: true,
showTabBar: false,
passProps: { ...},
}}/>
);
}
}
Tôi hy vọng điều này sẽ giúp người!
https://stackoverflow.com/questions/30266831/hide-show-components-in-react-native check this out. – ogelacinyc