开发者

Programmatically reinitiate an iPhone app?

I have a language toggle in my app and it would be rea开发者_Go百科lly easy to manage if when the user switches language I could present an activityIndicator and reinitialize all the views of the app with the new language default. Sort of how the iPhone settings manage language changes. Is there an easy way to do this?


Do you have a top level view, something like a UITabBarController or UINavigationController? If so, you could try removing it from it's superview (which should be your UIWindow) and creating a new one.

For example, in my app delegate I have:

// Add the tab bar controller's current view as a subview of the window
[window addSubview:self.tabBarController.view];
[window makeKeyAndVisible];

To redo this, you could try, in your app delegate:

[self.tabBarController.view removeFromSuperView];
self.tabBarController = //create a new tab bar controller
[window addSubview:self.tabBarController.view];

Maybe there is a better way, but this would probably be my first approach.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜