保存并检测iPhone上特定的摇晃手势模式

6
在我的项目中,我已经在iPhone上实现了摇晃手势。我想保存用户特定的摇晃模式(比如像单词“S”一样的摇晃),并且只需要在特定的模式下调用事件。这在iPhone上是否可行?如果可能,可以有人给我提供一些参考吗?

嘿,我也处于同样的情况。你能指导我一下吗?我想检测“z”运动。 - vivek bhoraniya
@vivek:抱歉兄弟,我已经离开了那个研发部门。 - Arun Kumar Munusamy
4个回答

3

谢谢您的回复。您提供的参考资料有些难以理解。是否有其他关于这个概念的工作示例或演示? - Arun Kumar Munusamy

2

我认为从这里可以了解如何在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"];

希望能对您有所帮助


2
“Seconding pradeepa,你需要学习使用Core Motion和UIAccelerometer API——可以从事件处理编程指南的{{link1:“运动事件”章节}}开始学习。”
“对于你的自定义形状运动识别器,你需要评估设备在(x/y/z)空间随时间的移动。”

2
这个项目AcceleroMusic可能会有所帮助。 您需要定义x、y、z来映射您特定的晃动模式(“S”型晃动)。

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接