I18nManager.forceRTL doesn't applies changes in first app load

后端 未结 5 1781
一生所求
一生所求 2021-02-18 21:37

I have an app that created by awesome React-native and my layout designed to be in RTL mode. I\'ve set up an option for forcing the layout to be RT

5条回答
  •  一向
    一向 (楼主)
    2021-02-18 22:15

    I had the same problem and solved it by invoking 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);
      }
    ...
    

    On IOS add in the AppDelegate.m

    ...
    NSURL *jsCodeLocation; // this probably already exists!
    [[RCTI18nUtil sharedInstance] allowRTL:YES];
    [[RCTI18nUtil sharedInstance] forceRTL:YES];
    ...
    

    Source

提交回复
热议问题