iPhone:实现摇动手势

iPhone:实现摇动手势,iphone,cocoa-touch,ios4,Iphone,Cocoa Touch,Ios4,在iPhone应用程序中如何实现摇动手势 请提供帮助和建议 谢谢查看文档至和事件(从此答案至)。如果您的ViewController启用了first responder,请在此处找到它 [self becomeFirstResponder] 并实现motionEnded:withEvent: - (void)motionEnded:(UIEventSubtype)motion withEvent:(UIEvent *)event { if (event.type == UIEventS

在iPhone应用程序中如何实现摇动手势

请提供帮助和建议


谢谢

查看文档至和事件(从此答案至)。

如果您的ViewController启用了first responder,请在此处找到它

[self becomeFirstResponder]
并实现motionEnded:withEvent:

- (void)motionEnded:(UIEventSubtype)motion withEvent:(UIEvent *)event {
    if (event.type == UIEventSubtypeMotionShake) {
        NSLog(@"Shake is detected");  
    }
}

从这个链接中,答案是:Eran Talmor在我的问题上很好