Change app language in iOS without restarting the app

后端 未结 6 795
时光取名叫无心
时光取名叫无心 2020-12-08 07:33

I have seems some apps can change the language internally within the app without the need of restarting the app, I am wondering how they are implemented.

For example

6条回答
  •  -上瘾入骨i
    2020-12-08 07:52

    I'm always using this way, it works perfectly, it might help you as well.


    you should set all the texts with NSLocalizableString(...) for the UI for the current language in the -viewWillAppear: method of your every UIViewController.

    using this way you (I mean, the users) don't need to restart the application after changing the language of iOS in the Settings.


    of course, I'm using the Apple's standard localisation architecture.

    UPDATE on (24 Oct 2013)

    I've experienced the –viewWillAppear: method won't be performed for the actual view when the application enters to foreground; to solve that issue I also commit the procedure (see above) when I receive UIApplicationWillEnterForegroundNotification notification in the view.

提交回复
热议问题