这些方法在 AppDelegate.m
- (void)applicationWillResignActive:(UIApplication *)application
{
/*
Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state.
Use this method to pause ongoing tasks, disable timers, and throttle down OpenGL ES frame rates. Games should use this method to pause the game.
*/
}
您可以在此处执行您的操作。但是,您可以在另一个视图控制器(如您的示例)中注册以“监听”该事件,但这只是为了更容易将该事件通知发送到该视图控制器。
1) 不,只是为了确保无论何时加载此 VC,它都能够侦听此事件。
2)不,仅适用于您想像这样轻松通过的人。然而,使用 appdelegate.m 并且每个的 vc 视图确实出现了更好。
3) depends on the kind of data you want to save, but typically you create your own file and just save it to disk like in any other OS. ios gives you access to the "documents" folder of your app and each folder is used for something specific, read the documentation.