-2

I need to detect handshake like action in iPhone. Once detecting the handshake action, need to do some other action. How to detect handshake like action. I searched about accelerometer and gyroscope. Shall i use both methods to detect and how?

Thanks.

iphony
  • 119
  • 9

1 Answers1

0

The snippet below detects a shake motion. If you want a motion to recognize a motion exactly like a handshake you are going to have to a bit more work. Here is a good resource though https://developer.apple.com/library/ios/documentation/EventHandling/Conceptual/EventHandlingiPhoneOS/motion_event_basics/motion_event_basics.html

- (void)motionEnded:(UIEventSubtype)motion withEvent:(UIEvent *)event {
    if (motion == UIEventSubtypeMotionShake)
    {
        // User was shaking the device. Post a notification named "shake."
        [[NSNotificationCenter defaultCenter] postNotificationName:@"shake" object:self];
     }
}
TheSD
  • 873
  • 5
  • 17
  • I have tried this UIEvent methods. But it recognizes all kinds of shake. But I need to recognize a motion exactly like handshake. – iphony Jan 28 '15 at 04:57