在iOS中,有没有一种方法可以在我退出应用程序后一定时间后执行一段代码?

在iOS中,有没有一种方法可以在我退出应用程序后一定时间后执行一段代码?,ios,Ios,我退出应用程序后,有没有办法在一定时间后执行一段代码 我的意思是按主页按钮: 在iOS 4.0及更高版本中,当按下主页按钮且用户视图退出主屏幕时,将在appDelegate上调用ApplicationIdentinterBackground方法。然后可以使用[NSTimer] () 在以后的某个时候执行您想要的任何代码。不过请注意,iOS喜欢ApplicationIdentinterBackground在大约5秒钟内返回;应用程序可以使用方法beginBackgroundTaskWithExpi

我退出应用程序后,有没有办法在一定时间后执行一段代码

我的意思是按主页按钮

在iOS 4.0及更高版本中,当按下主页按钮且用户视图退出主屏幕时,将在
appDelegate
上调用
ApplicationIdentinterBackground
方法。然后可以使用[
NSTimer
]

()

在以后的某个时候执行您想要的任何代码。不过请注意,iOS喜欢
ApplicationIdentinterBackground
在大约5秒钟内返回;应用程序可以使用方法
beginBackgroundTaskWithExpirationHandler

启动后台任务:

在iOS 4.0及更高版本中,当按下主页按钮且用户视图退出主屏幕时,将在
appDelegate
上调用
ApplicationIdentinterBackground
方法。然后可以使用[
NSTimer
]

()

在以后的某个时候执行您想要的任何代码。不过请注意,iOS喜欢
ApplicationIdentinterBackground
在大约5秒钟内返回;应用程序可以使用方法
beginBackgroundTaskWithExpirationHandler

启动后台任务:

在iOS 4.0及更高版本中,当按下主页按钮且用户视图退出主屏幕时,将在
appDelegate
上调用
ApplicationIdentinterBackground
方法。然后可以使用[
NSTimer
]

()

在以后的某个时候执行您想要的任何代码。不过请注意,iOS喜欢
ApplicationIdentinterBackground
在大约5秒钟内返回;应用程序可以使用方法
beginBackgroundTaskWithExpirationHandler

启动后台任务:

在iOS 4.0及更高版本中,当按下主页按钮且用户视图退出主屏幕时,将在
appDelegate
上调用
ApplicationIdentinterBackground
方法。然后可以使用[
NSTimer
]

()

在以后的某个时候执行您想要的任何代码。不过请注意,iOS喜欢
ApplicationIdentinterBackground
在大约5秒钟内返回;您的应用程序可以通过以下方法启动后台任务:
beginBackgroundTaskWithExpirationHandler

您的应用程序代理的应用程序标识符背景:方法已禁用 大约5秒钟完成任何任务并返回。实际上,, 此方法应尽快返回。如果该方法 未在时间结束前返回,您的应用程序将被终止并从中清除 记忆。如果您仍需要更多时间执行任务,请致电 beginBackgroundTaskWithExpirationHandler:方法请求后台执行时间,然后在 次级线程。不管你是否开始任何背景 任务时,ApplicationIdentinterBackground:方法仍必须退出 在5秒内

阅读整篇文章了解更多信息,但基本上当有人按下home按钮时,
ApplicationIdentinterBackground:
方法将被调用。在该方法中,使用
beginBackgroundTaskWithExpirationHandler:
在单独的线程上设置代码

希望有帮助

来自:

您的应用程序代理的应用程序标识符背景:方法已禁用 大约5秒钟完成任何任务并返回。实际上,, 此方法应尽快返回。如果该方法 未在时间结束前返回,您的应用程序将被终止并从中清除 记忆。如果您仍需要更多时间执行任务,请致电 beginBackgroundTaskWithExpirationHandler:方法请求后台执行时间,然后在 次级线程。不管你是否开始任何背景 任务时,ApplicationIdentinterBackground:方法仍必须退出 在5秒内

阅读整篇文章了解更多信息,但基本上当有人按下home按钮时,
ApplicationIdentinterBackground:
方法将被调用。在该方法中,使用
beginBackgroundTaskWithExpirationHandler:
在单独的线程上设置代码

希望有帮助

来自:

您的应用程序代理的应用程序标识符背景:方法已禁用 大约5秒钟完成任何任务并返回。实际上,, 此方法应尽快返回。如果该方法 未在时间结束前返回,您的应用程序将被终止并从中清除 记忆。如果您仍需要更多时间执行任务,请致电 beginBackgroundTaskWithExpirationHandler:方法请求后台执行时间,然后在 次级线程。不管你是否开始任何背景 任务时,ApplicationIdentinterBackground:方法仍必须退出 在5秒内

阅读整篇文章了解更多信息,但基本上当有人按下home按钮时,
ApplicationIdentinterBackground:
方法将被调用。在该方法中,使用
beginBackgroundTaskWithExpirationHandler:
在单独的线程上设置代码

希望有帮助

来自:

您的应用程序代理的应用程序标识符背景:方法已禁用 大约5秒钟完成任何任务并返回。实际上,, 此方法应尽快返回。如果该方法 未在时间结束前返回,您的应用程序将被终止并从中清除 记忆。如果您仍需要更多时间执行任务,请致电 beginBackgroundTaskWithExpirationHandler:请求backgr的方法
[NSTimer scheduledTimerWithTimeInterval:60.0
                                                 target:self
                                               selector:@selector(MethodName)
                                               userInfo:nil
                                                repeats:YES];