2

I am implementing multiple language support in a app. Can any one say how to reload storyboard to change localised text without restart of app?

kishan
  • 203
  • 1
  • 6
  • 15
  • 1
    Possible duplicate of [Reload storyboard to change locale](http://stackoverflow.com/questions/21304988/reload-storyboard-to-change-locale) – CupawnTae May 05 '17 at 17:51

1 Answers1

2

To reload storyboard you need to set RootViewController on changing language. You can use bellow line of code to set RootViewController:

  let firstVC = UIStoryboard(name: "Main", bundle: nil).instantiateViewController(withIdentifier: "FirstViewController")
  let rootviewcontroller: UIWindow = ((UIApplication.shared.delegate?.window)!)!
  rootviewcontroller.rootViewController = firstVC

If you want to embed navigation controller in firstVC you should use following line of code:

  let firstVC = UIStoryboard(name: "Main", bundle: nil).instantiateViewController(withIdentifier: "FirstViewController")
  let nav = UINavigationController(rootViewController: firstVC)
  let rootviewcontroller: UIWindow = ((UIApplication.shared.delegate?.window)!)!
  rootviewcontroller.rootViewController = nav
Umair Ali
  • 758
  • 8
  • 17