目标 C:检测震动
我像这样使用 shake api:
- (void)motionEnded:(UIEventSubtype)motion withEvent:(UIEvent *)event
{
if (event.subtype == UIEventSubtypeMotionShake)
{
[img stopAnimating];
}
}
How do I detector that shake has stop?
I'm using the shake api like this:
- (void)motionEnded:(UIEventSubtype)motion withEvent:(UIEvent *)event
{
if (event.subtype == UIEventSubtypeMotionShake)
{
[img stopAnimating];
}
}
How do I detect that the shaking has stopped?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您的方向是正确的,但是,您还需要添加更多内容来检测晃动:
您可以通过向
motionBegan
或添加
方法,然后在模拟器中按NSLog
来测试这一点>motionEndedCONTROL + COMMAND + Z
You are on the right track, however, there are still more things you need to add to detect shaking:
You can test this by adding an
NSLog
to themotionBegan
ormotionEnded
methods, and in the Simulator, pressCONTROL + COMMAND + Z