当我的应用再次变为活动状态时如何重新加载我的视图?

cgo*_*ain 2 iphone ios4

假设有人正在使用我的应用程序并更改设置包中的设置,当他们回到我的应用程序时,我希望我的视图根据这些设置更新(通过我的更新方法).我尝试了很多不同的东西,但我无法让它发挥作用.

为我的iPhone应用程序实现这种行为的最佳方法是什么?

con*_*are 6

在你AppDelegate这些方法中:

- (void)applicationWillEnterForeground:(UIApplication *)application {
    /*
     Called as part of  transition from the background to the active state: here you can undo many of the changes made on entering the background.
     */
}


- (void)applicationDidBecomeActive:(UIApplication *)application {
    /*
     Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface.
     */
}
Run Code Online (Sandbox Code Playgroud)

然后你有钩子做你想做的任何事情.