iPhone:实现摇动手势

问题描述:

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

请帮助和建议。

感谢

+0

从这个链接,通过给出的答复:叶兰塔尔莫尔工作正常我的问题 – ios 2011-03-09 11:38:10

看的文档,以UIResponderUIEventSubtypeMotionShake事件(从这个答案another SO question)。

如果您的视图控制器使第一响应

[self becomeFirstResponder] 

和实施motionEnded:withEvent:方法

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