我希望我的图片上传应该在后台工作。我启用了后台模式,并创建了一个操作队列,以便一次将多个文件上载到服务器。但只要将应用程序放到后台,NSOperation就会暂停,并在前台重新启动。当所有图像上传到服务器时,我还在启动操作队列和beginBackgroundTaskWithExpirationHandler之前添加了endBackgroundTask。
这使得所有的图片上传到服务器时,应用程序也在后台,但我的应用程序正在被杀死,我不希望应用程序被杀死。
请对我的问题提出一些解决办法。
发布于 2015-06-20 14:48:00
在后台运行时,应用程序的时间有限。它的分配时间已经过了,它就被杀死了。
据苹果公司称:
In your own expiration handlers, you can include additional code needed
to close out your task. However, any code you include must not take too
long to execute because, by the time your expiration handler is called,
your app is already very close to its time limit. For this reason,
perform only minimal cleanup of your state information and end the
task.还可以获取backgroundTimeRemaining属性的值,以检查剩余时间。
https://stackoverflow.com/questions/30955184
复制相似问题