iphone 接收搖動事件
關(guān)鍵詞: ios iphone shake gesture UIView
在 ios3.0 之后, UIView 提供了三個函數(shù)接收搖動事件
motionBegan:
motionEnded:
motionCancelled:
只需要繼承 UIView 并實現(xiàn)以上函數(shù)即可.
需要注意的事項:
1. 這個UIView 要成為事件響應(yīng)者, 也就是顯示之后 becomeFirstResponder
2. 更加重要! 這個 UIView 要實現(xiàn) canBecomeFirstResponder 函數(shù)并且返回 YES. 否則上一條建議無效.
參考資料: http://www.iphonedevsdk.com/forum/iphone-sdk-development/4381-iphone-shaking-code.html
motionBegan: motionEnded: motionCancelled:
浙公網(wǎng)安備 33010602011771號