关键词: ios iphone shake gesture UIView

在 ios3.0 之后, UIView 提供了三个函数接收摇动事件

motionBegan:

motionEnded:

motionCancelled:

只需要继承 UIView 并实现以上函数即可.

需要注意的事项:

1. 这个UIView 要成为事件响应者, 也就是显示之后 becomeFirstResponder

2. 更加重要! 这个 UIView 要实现 canBecomeFirstResponder 函数并且返回 YES. 否则上一条建议无效.

 

参考资料: http://www.iphonedevsdk.com/forum/iphone-sdk-development/4381-iphone-shaking-code.html

motionBegan: motionEnded: motionCancelled:

相关文章:

  • 2022-12-23
  • 2022-01-13
  • 2021-11-16
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-05-16
  • 2022-01-17
猜你喜欢
  • 2021-09-10
  • 2022-12-23
  • 2022-01-21
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-11-18
相关资源
相似解决方案