模拟iPhone的电池电量不足 [英] Simulating low battery for iPhones

查看:226
本文介绍了模拟iPhone的电池电量不足的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在开发一个手机游戏,当显示电量不足"警报时,该游戏似乎崩溃了.在内存不足,来电和其他消息时,它可以正常工作.

I am working on a mobile game, which appearantly crashes when the Low Battery alert is displayed. It works fine on low memory, incoming calls and other messages.

测试和调试它很痛苦,因为我找不到模拟这种情况的终端机或iPhone模拟器,因此我必须给手机充电一点,启动应用程序,等待它耗尽电量,然后重新开始.

Its a pain to test and debug this, since I can find no terminal or iPhone simulator way of simulating this situation, so I have to charge my phone up a little bit, launch the app, wait for it to drain its power, and start all over again.

有人知道以现实的方式产生此错误的方法吗?希望我的iPhone电池没什么压力.

Does anyone know of a way to produce this error in a realistic way? Hopefully something that isn't too stressful on my iPhone battery.

推荐答案

不幸的是,没有很好的方法来模拟电池电量不足的环境.实际上,您实际上很可能需要对设备的电池进行物理充电,直到它刚好处于低电量"状态,然后调试应用程序.

Unfortunately, there is no good way to simulate a low-battery environment. You actually will most likely need to physically charge your device's battery until it is just above the "low battery" state and then debug your application.

解决其他人所说的话:

  1. 无法模拟电池电量不足的通知.该项目 那@Bo.提供的无非是安排随机 UILocalNotifications.并没有什么太大的不同 在您的应用中显示UIAlertView.
  2. 您可以尝试@AndrewR. 说并使用 UIDevice标头中的私有方法. 但令人怀疑的是,您是否会精确模仿真实物体的效果? 电池电量不足的环境.
  1. There is no way to simulate low battery notifications. The project that @Bo. provided does nothing more than schedule random UILocalNotifications. It isn't all that much different than just showing a UIAlertView in your app.
  2. You could try what @Andrew R. said and use the private methods found in the UIDevice header. But it is doubtful that you will exactly mimic the effects of a real low-battery environment.

尽管必须等待设备实际达到低电量状态是很痛苦的,但是您可以在应用中添加一些耗电代码来为您提供帮助.例如,使用GPS可能会更快耗尽电池电量.

Although it is a pain to have to wait for you device to actually hit the low-battery state, you could add some battery-draining code to your app to assist you. For example, using the GPS might drain the battery a bit quicker.

祝你好运.

这篇关于模拟iPhone的电池电量不足的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆