保存并检测特定的摇动手势模式iphone

时间:2013-01-15 07:31:27

标签: iphone ios xcode ipad

在我的项目中,我已经在iPhone中实现了摇动手势。我想从用户那里保存一个特定的摇动模式(比如,像“S”这样的单词摇动),我只需要在特定模式上调用事件。这可能在iPhone?如果可能的话,有人可以引导我一些参考吗?

4 个答案:

答案 0 :(得分:3)

浏览 Core motion programming guideCore motion framework reference。并了解iPhone设备动作apis,您将能够实现自定义动作事件。

答案 1 :(得分:2)

借调pradeepa,您需要学习使用Core Motion和UIAccelerometer API - 从"Motion Events" chapter in the Event Handling Programming Guide开始。

对于自定义形状运动识别器,您需要评估设备在(x / y / z-)空间中随时间的移动。

答案 2 :(得分:2)

这个项目可能有所帮助,AcceleroMusic。 您需要定义x,y,z以映射您的特定抖动模式(“S”抖动)。

答案 3 :(得分:2)

是的,我认为Hear对iphone有震撼效果, 或者你可以使用

CABasicAnimation *theAnimation; 
theAnimation=[CABasicAnimation animationWithKeyPath:@"transform.translation.x"];
theAnimation.duration=1;
theAnimation.repeatCount=2;
theAnimation.autoreverses=YES;
theAnimation.fromValue=[NSNumber numberWithFloat:0];
theAnimation.toValue=[NSNumber numberWithFloat:-60];
[view.layer addAnimation:theAnimation forKey:@"animateLayer"];

希望它会帮助你

相关问题