iPhone:实现摇动手势

时间:2011-03-09 10:12:20

标签: iphone cocoa-touch ios4

在iPhone App中如何实现摇动手势?

请帮助并建议。

由于

3 个答案:

答案 0 :(得分:2)

如果您的ViewController启用第一响应者

[self becomeFirstResponder]

并实现motionEnded:withEvent:

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

答案 1 :(得分:1)

答案 2 :(得分:0)

查看UIResponderUIEventSubtypeMotionShake事件的文档(从another SO question的答案)。

相关问题