问题描述
我知道在 iOS 4 ,Wi-Fi连接以前是持久的,因此进入睡眠模式/锁定保持连接打开。
这是在下一个版本 iOS 5 中修改的,以延长电池寿命。
在 iOS 5 中,需要将设备插入电源才能拥有持续的Wi-Fi连接。
iPad进入睡眠模式/锁定后,Wi-Fi连接会自动断开连接。
问题,我通过WiFi发送大量数据,这可能需要太多时间。因此,用户必须等待交易完成。
iPad可能会切换到睡眠模式/锁定,发送过程需要更多的时间,这将导致WiFi连接错误。 / p>
现在我已在info.plist中将 UIRequiresPersistentWiFi 设置为 YES 。
我想保持/持续WiFi连接,即使iPad进入睡眠模式/锁定在 iOS5 。
感谢。
Phew ...最后,我得到一个解决方案与 idleTimerDisabled
。
布林值,用于控制是否为应用程序禁用闲置计时器。
它是防止iPad在我的应用程序运行时睡眠的方法。
此属性的默认值为 NO
。当大多数应用程序在短时间内没有作为用户输入的触摸时,系统将设备置于 睡眠
状态,其中屏幕变暗。
这是为了节省电量,但是除了加速度计游戏以外没有用户输入的应用程序,属性设置为 YES
,请停用 空闲计时器
以避免系统睡眠。
我只是将值设置为 YES
NO
。
示例: [[UIApplication sharedApplication] setIdleTimerDisabled:YES];
注意:当您的应用不需要阻止屏幕锁定时,请务必将此属性重置为NO。
更多详情
I know that on iOS 4, the Wi-Fi connection used to be persistent, so going into sleep mode/locked kept the connection ON .
This was modified in the next version iOS 5 to improve battery life.
In iOS 5 , requiring the device to be plugged into a power source in order to have a persistent Wi-Fi connection.
Wi-Fi connection is disconnecting automatically after iPad is going into sleep mode/locked .
Here comes my problem, I'm sending a bulk chunk of data through WiFi which may take too much time. So the user have to wait up to the transaction complete.
iPad may switch into sleep mode/locked while sending process took more time which will result the WiFi connection error.
Now i have set the UIRequiresPersistentWiFi to YES in info.plist. However same network issue happened again.
I would like to keep/persistent the WiFi Connection active even iPad is going into sleep mode/locked in iOS5. So is there any alternatives to achieve this.
Thanks.
Phew... Finally I got a solution with idleTimerDisabled
.
Its a Boolean value that controls whether the idle timer is disabled for the application .
Its the way to prevent the iPad from sleeping while my application is running.
The default value of this property is NO
. When most applications have no touches as user input for a short period, the system puts the device into a "sleep
" state where the screen dims.
This is done for the purposes of conserving power. However, applications that don't have user input except for the accelerometer—games, for instance—can, by setting this property to YES
, disable the "idle timer
" to avert system sleep.
I just set the value to YES
while I'm sending a bulk chunk of data through WiFi and have set the value to NO
when the process is completed.
Example:[[UIApplication sharedApplication] setIdleTimerDisabled:YES];
Note: Be sure to reset this property to NO when your app does not need to prevent screen locking.
You can see more details here
这篇关于即使iPad进入睡眠模式/在iOS 5锁定,保持WiFi连接活动的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!