0

我想要一个功能,我想检测我的设备是否正在摇晃。问题是我可以使用 UIAcceleratorDelegate 的 didAccelerate 方法检测摇晃,但我不知道如何检测设备是否仍在摇晃。我想在用户第一次摇动设备时播放音频文件,我必须检查用户在播放第一个音频文件时是否还在摇动设备,如果它仍然在摇动,那么我必须播放另一个文件.

4

2 回答 2

0

You might consider writing a Method that runs in a separate thread that polls wether your device is being shaken every now and then and fire events that you handle somewhere else in your code (or instead of that, handle whatever you want to handle within the threads context itself, even tough i would not recommend doing that).

You just have to make sure, that your "shake-detektor"-thread exits at some point in time, you probably want to do that when the second audio file stopped playing. So your loop could test on that condition.

Hope I could help a bit.

于 2010-07-05T12:12:32.977 回答
0

访问http://developer.apple.com/iphone并在搜索框中输入“shake”,查看来自 Apple的示例项目GLPaint 。不需要开发者帐户。

于 2010-07-05T18:31:56.053 回答