这是一个真正的新手:
如何在多个对象中注册UIApplicationWillTerminateNotification?
谢谢!
发布于 2011-05-08 08:19:22
在iOS4中,支持后台执行的应用程序通常不会调用applicationWillTerminate。这可能就是你遇到问题的原因。
如果禁用了该功能,则可以注册对象以侦听UIApplicationWillTerminateNotification通知,和/或覆盖应用程序委托-applicationWillTerminate:方法并将代码放在其中:
//set up this class as an observer of UIApplicationWillTerminateNotification
//so we can intervene when the app is about to exit.
[[NSNotificationCenter defaultCenter]
addObserver:self
selector:@selector(applicationWillTerminate:)
name:UIApplicationWillTerminateNotification
object:[UIApplication sharedApplication]];https://stackoverflow.com/questions/3371547
复制相似问题