ios - 反应原生 forceRTL false 在 iOS 上不起作用
问题描述
我在这里阅读了解决方案:React native - ios 中的 rtl,它对我有用,我成功地在 android 和 iOS 上设置了 RTL 方向。
现在,我尝试在 android 上设置 FORCERTL(false),在 iOS 上仍然是 RTL。
这是我的 appDelegate.m 文件代码:
#import "AppDelegate.h"
#import <React/RCTBridge.h>
#import <React/RCTBundleURLProvider.h>
#import <React/RCTRootView.h>
#import <React/RCTI18nUtil.h>
#ifdef FB_SONARKIT_ENABLED
#import <FlipperKit/FlipperClient.h>
#import <FlipperKitLayoutPlugin/FlipperKitLayoutPlugin.h>
#import <FlipperKitUserDefaultsPlugin/FKUserDefaultsPlugin.h>
#import <FlipperKitNetworkPlugin/FlipperKitNetworkPlugin.h>
#import <SKIOSNetworkPlugin/SKIOSNetworkAdapter.h>
#import <FlipperKitReactPlugin/FlipperKitReactPlugin.h>
static void InitializeFlipper(UIApplication *application) {
FlipperClient *client = [FlipperClient sharedClient];
SKDescriptorMapper *layoutDescriptorMapper = [[SKDescriptorMapper alloc] initWithDefaults];
[client addPlugin:[[FlipperKitLayoutPlugin alloc] initWithRootNode:application withDescriptorMapper:layoutDescriptorMapper]];
[client addPlugin:[[FKUserDefaultsPlugin alloc] initWithSuiteName:nil]];
[client addPlugin:[FlipperKitReactPlugin new]];
[client addPlugin:[[FlipperKitNetworkPlugin alloc] initWithNetworkAdapter:[SKIOSNetworkAdapter new]]];
[client start];
}
#endif
@implementation AppDelegate
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
[[RCTI18nUtil sharedInstance] forceRTL:YES];
#ifdef FB_SONARKIT_ENABLED
InitializeFlipper(application);
#endif
RCTBridge *bridge = [[RCTBridge alloc] initWithDelegate:self launchOptions:launchOptions];
RCTRootView *rootView = [[RCTRootView alloc] initWithBridge:bridge
moduleName:@"JeliveryProject"
initialProperties:nil];
if (@available(iOS 13.0, *)) {
rootView.backgroundColor = [UIColor systemBackgroundColor];
} else {
rootView.backgroundColor = [UIColor whiteColor];
}
self.window = [[UIWindow alloc] initWithFrame:[UIScreen mainScreen].bounds];
UIViewController *rootViewController = [UIViewController new];
rootViewController.view = rootView;
self.window.rootViewController = rootViewController;
[self.window makeKeyAndVisible];
return YES;
}
- (NSURL *)sourceURLForBridge:(RCTBridge *)bridge
{
#if DEBUG
return [[RCTBundleURLProvider sharedSettings] jsBundleURLForBundleRoot:@"index" fallbackResource:nil];
#else
return [[NSBundle mainBundle] URLForResource:@"main" withExtension:@"jsbundle"];
#endif
}
@end
而且,这是我的 App 容器:
import React from 'react';
import {Text,I18nManager} from 'react-native';
import {NavigationContainer} from '@react-navigation/native';
import {AuthStack} from './AuthStack';
export function AppContainer(props){
I18nManager.allowRTL(true);
I18nManager.forceRTL(true);
const {isAuthenticated} = props;
return(
<NavigationContainer>
<AuthStack />
</NavigationContainer>
);
}
任何人都可以帮助如何将应用程序重置为 LTR ?
解决方案
推荐阅读
- html - 孩子的`height: 100%;`没有取父母的全高,为什么?
- django - 未创建对象
- mongodb - 大型数据库中与 $nin/$ne 查询相关的性能问题
- python - 如何更新 django 模板中 db 字段的值
- python - Python打印元素发生在下一个元素之后
- docker-compose - 管理员用户在 Rocketchat 中失败
- python - 除非我退出脚本,否则谷歌云操作卡在 RUNNING
- reactjs - 制表符 - 自定义单元格编辑器未完全打开
- python - 对 python 请求使用多个 CA 证书
- ios - SwiftUI 中的自定义 TabView 导航