问题描述
我的应用程序以无线方式与外部设备通信。我想阻止用户关闭应用程序,直到收到设备的响应,这可能需要几秒钟。
My app communicates wirelessly to an external device. I want to prevent the user from closing the app until a response is received from the device, which can take a few seconds.
在ViewController.viewWillDisappear以及appDelegate中.applicationWillTerminate我可以把逻辑看看还有什么东西要做,但我无法确定如何让应用程序无法关闭!
In the ViewController.viewWillDisappear and also the appDelegate.applicationWillTerminate I can put logic to see if there is still something left to do, but I can't determine how to keep the app from closing anyway!
我认识到如果应用程序没有快速关闭,手机的性能看起来会很糟糕,但我会提出一个视图,向用户解释应用程序必须在关闭之前完成并耐心等待。
I recognize that the 'performance' of the phone will look bad if the app doesn't close quickly, but I would put up a view explaining to the user that the app must complete before shutting down AND be patient.
任何人都知道这样做的方法吗?
Anyone know of a way to do this?
推荐答案
抱歉,您无法阻止该应用从戒烟。如果您尝试停止应用程序退出,iOS将终止您的程序。
Sorry, you can't prevent the app from quitting. If you try to stop the app from quitting, the iOS will terminate your program.
使用iOS 4.0,您可以拥有允许在后台完成的任务。退房:
With iOS 4.0, you can have tasks that are allowed to complete in the background. Check out: http://developer.apple.com/iphone/library/documentation/iPhone/Conceptual/iPhoneOSProgrammingGuide/BackgroundExecution/BackgroundExecution.html
有关运行任务的概述。
这篇关于如何阻止iPhone应用程序关闭,直到所有活动完成的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!