我有一个由 Awesome 创建的应用程序React-native
我的布局设计为 RTL 模式。我已经设置了一个强制布局为 RTL 的选项,但我的选项在安装后的第一次应用程序加载中不起作用。此功能适用于第二次运行。
我在我们的index.js中写了这个选项:
import React, { Component } from 'react';
import { I18nManager } from 'react-native';
import { Provider } from 'react-redux';
I18nManager.forceRTL(true);
class App extends Component {
render() {
return (
<Provider store={store}>
<PersistGate loading={null} persistor={persistor}>
<MainStack />
</PersistGate>
</Provider>
);
}
}
export default App;
我遇到了同样的问题并通过调用解决了它forceRTL
in MainApplication.java
in the onCreate
method.
...
import com.facebook.react.modules.i18nmanager.I18nUtil;
...
@Override
public void onCreate() {
super.onCreate();
SoLoader.init(this, /* native exopackage */ false);
I18nUtil sharedI18nUtilInstance = I18nUtil.getInstance();
sharedI18nUtilInstance.forceRTL(this,true);
sharedI18nUtilInstance.allowRTL(this, true);
}
...
在 IOS 上添加AppDelegate.m
...
NSURL *jsCodeLocation; // this probably already exists!
[[RCTI18nUtil sharedInstance] allowRTL:YES];
[[RCTI18nUtil sharedInstance] forceRTL:YES];
...
Source https://github.com/facebook/react-native/issues/11475#issuecomment-377877404
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)