0

How can I switch language between applications in an efficient and simple way?

My current practice is to write a Singleton

There is a way to reset the rootViewController in a single instance

This approach if the root view of the different circumstances, how to dynamically reset

For example, the root view is of type UIViewController or UITabBarController

There are several flaws in the way to reset the root view

  1. sometimes can not stay in the switch language page

For example, the root view is a UIViewController, and the page into the toggle language is UITabController

  1. if it is UITabBarController, viewControllers page, a large number of data requests, and switch the language will re-request, it is obviously very unreasonable

  • Another approach is to use NotificationCenter, but this approach I think in my entire application need to register a lot of Notification is not suitable for large-scale use

I hope you can guide me about how to do the application of switching language, I can use either Objective-C or Swift

If there is a better way to tell me Thank you very much

SnowStorm-L
  • 165
  • 11
  • Why don't you register your singleton instances or any other instance to a certain callback lets say an Array holding instances that implement a certain delegate "changeLanguage:" or something and when you change the language all delegates will get informed about the update? --> LanguageCallbackHandler with NSArray *languageUpdateCallbacks and the delegate/protocol that will require the related delegate to implement the "update" function – Lepidopteron May 16 '17 at 13:52
  • 1
    Possible duplicate of [Swift : How to change language inside app?](http://stackoverflow.com/questions/37111409/swift-how-to-change-language-inside-app) – Satish Babariya May 16 '17 at 14:01
  • Can you say more detail? Or give some example code MultiLanguage.shared.callBack {([LanguageUpdateDelegate]) in } Is it like this? and how it should be done – SnowStorm-L May 16 '17 at 14:10

0 Answers0