gre*_*ory 5 right-to-left ios react-native
首先,我在 android 上工作并且 RTL 运行良好,我添加了以下代码:
I18nUtil sharedI18nUtilInstance = I18nUtil.getInstance();
sharedI18nUtilInstance.setAllowRTL(context, true);
Run Code Online (Sandbox Code Playgroud)
到 MainActivity.java 和
android:supportsRtl="true"
Run Code Online (Sandbox Code Playgroud)
到 AndroidManifest.xml
并在js代码中:
I18nManager.forceRTL(true);
Run Code Online (Sandbox Code Playgroud)
现在是问题:我尝试在 ios 上设置 rtl 但它不起作用我添加了
// in AppDelegate.m
[[RCTI18nUtil sharedInstance] allowRTL:YES];
Run Code Online (Sandbox Code Playgroud)
和
I18nManager.forceRTL(true);
Run Code Online (Sandbox Code Playgroud)
在 js 代码中,但所有文本和 flex 仍然是 ltr...我能做什么?
无需将 RTL 语言添加到您的项目中。只需打开你的AppDelegate.m文件in yourProject/ios/YourProject/AppDelegate.m
注意不要打开另一个与此.h扩展名类似的文件
现在,添加 #import <React/RCTI18nUtil.h> 到代码顶部,如下所示:
#import "AppDelegate.h"
#import <React/RCTBridge.h>
#import <React/RCTBundleURLProvider.h>
#import <React/RCTRootView.h>
#import <React/RCTI18nUtil.h> <-- added here
Run Code Online (Sandbox Code Playgroud)
现在重新启动并重建您的应用程序。
现在您可以轻松更改整个应用程序的 RTL 方向I18nManager。
import {I18nManager} from "react-native"
I18nManager.forceRTL(true) // false for LTR direction
Run Code Online (Sandbox Code Playgroud)
即使添加新的 RTL 语言,我的问题也没有解决。最后,我通过将以下行添加到我的AppDelegate.m文件中didFinishLaunchingWithOptions函数内部的allow RTL行下解决了这个问题[[RCTI18nUtil sharedInstance] allowRTL:YES];:
[[RCTI18nUtil sharedInstance] forceRTL:YES];
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
3030 次 |
| 最近记录: |