当应用程序从跳板返回时调用的方法

时间:2010-12-27 22:34:30

标签: iphone

我需要以下行为:

用户点击主页按钮,即可将我的应用留在“应用内设置”视图中。然后他/她在iphone设置视图中进行了一些更改,然后再次打开我的应用程序。我需要使用哪种方法添加代码才能在“应用内设置”视图中更新用户界面?

提前致谢

2 个答案:

答案 0 :(得分:1)

将简历代码放入app delegate .m文件中的- (void) applicationDidBecomeActive:(UIApplication *)application- (void)applicationWillEnterForeground:(UIApplication *)application函数中。当用户点击主页按钮后你的应用程序再次启动时,将调用此函数

apple的文档更详细地解释了用于某些任务的功能:

http://developer.apple.com/library/ios/#documentation/uikit/reference/UIApplicationDelegate_Protocol/Reference/Reference.html

答案 1 :(得分:1)

将此添加到您的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.
         */
}

viewWillAppear未被调用,因为当应用程序处于后台/暂停时,视图仍然存在。