以编程方式更改 Xib 方向的最佳方法 [英] Best approach to change Xib direction programmatically

查看:48
本文介绍了以编程方式更改 Xib 方向的最佳方法的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个应用程序,它有一个设置页面,用户可以在其中更改应用程序的语言.最终,xib 的方向会改变.再解释一下,如果语言是英语,那么方向就是LTR;但是,如果是阿拉伯语,则是 RTL.

I have an app that has a settings page in which the user can change the app's language. Eventually, the direction of the xibs will change. To explain a bit more, if the language is English for example, the direction will be LTR; However if it's Arabic, it will be RTL.

问题

实现这一目标的最佳方法是什么?

What is the best approach to achieve this?

尝试的方法有问题

  • NSUserDefaults : 将语言设置为ar-SA"时,方向更改成功,但在主类中调用时.当我在运行时执行此操作时,必须重新启动应用程序才能生效.即使有重启应用的方法,也不推荐,应用有被拒绝的风险
  • 多个xib:这种方法最终会奏效,但我必须为每个UIView创建两个Xibs文件.如果这是唯一的解决方案,我可以在一个 xib 文件中创建两个 UIView 以避免混淆吗?
  • NSUserDefaults : When setting the language to "ar-SA", the direction changes successfully but only when it's called in the main class. When I do it in runtime, the app must be restarted to take effect. Even if there's a way to restart the app, it's not recommended and the app risks to be rejected
  • Multiple xibs : This approach will work eventually but I have to create two Xibs files for each UIView. If this is the only solution, can I create two UIViews in one xib file to avoid the confusion?

还有什么建议吗?

谢谢

推荐答案

我强烈建议您放弃应用程序内的语言切换器,并将您的用户引导至系统范围的语言 &区域偏好,他们可以在其中设置他们的推荐语言.

I highly recommend ditching the in-app language switcher and directing your users to the system-wide language & region prefs where they can set their referred language.

尝试在您的应用中手动滚动语言支持会给您的用户带来无穷无尽的问题和错误,其中一些您甚至可能无法解决.您提供的两种方法都已经低于标准,第二种听起来像是可维护性的噩梦.

Attempting to hand roll language support in your app will cause an endless amount of issues and bugs for your users, some of which you might not even be able to workaround. Both approaches you provide are already subpar and the second sounds like a maintainability nightmare.

这篇关于以编程方式更改 Xib 方向的最佳方法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆