我正在应用中实现多语言支持。任何人都可以说如何重新加载故事板以更改本地化文本而无需重新启动应用程序?
答案 0 :(得分:0)
要重新加载故事板,您需要在更改语言时设置RootViewController。您可以使用以下代码行来设置RootViewController:
let firstVC = UIStoryboard(name: "Main", bundle: nil).instantiateViewController(withIdentifier: "FirstViewController")
let rootviewcontroller: UIWindow = ((UIApplication.shared.delegate?.window)!)!
rootviewcontroller.rootViewController = firstVC
如果要在firstVC中嵌入导航控制器,则应使用以下代码行:
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