问题描述
我的应用程序崩溃是因为自动锁定设置时间为2分钟,而我的网络服务时间超过2分钟。
如果时间超过2分钟,那么我的应用程序每次都会崩溃。
My app is crashing because of the auto-lock setting time is 2 min and my web-serevice is taking time more than 2 min.if time goes over 2 min then my app crashed every time.
但我不想将自动锁定时间设置为15分钟或从不从设置。
我想在应用程序中使用一些解决方案而不更改设置值。
but i don't want to set the auto-lock time to 15 min or never from setting.I want some solution within the app without changing the setting value.
如果有人知道解决方案以避免崩溃,请告诉我。
please let me know if any one know the solution to avoid the crash.
谢谢。
推荐答案
您可以暂时关闭自动锁定,直到请求已完成,即 [UIApplication sharedApplication] .idleTimerDisabled
设置为是
。
You can turn off auto-lock temporarily until the request is completed, that is set [UIApplication sharedApplication].idleTimerDisabled
to YES
.
另一种选择是将您的网络服务请求设置为,因此即使您的设备进入休眠状态,请求也会继续运行。请注意10分钟的时间限制。
The other option is to set your web service request up as a finite-length task running in background, so even if your device goes to sleep, the request keeps running. Watch out for the 10-minute time limit though.
无论哪种方式,在前台运行时,请确保请求是异步完成的,并且不会阻止主线程或这样做太长时间后你的应用程序总会被杀死。
Either way, when running in foreground, make sure the request is done asynchronously and doesn't block the main thread or your app will always get killed after doing that for too long.
这篇关于因iPhone中的自动锁定应用程序崩溃?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!