ios
ios

Reputation: 6164

iPhone :implement shake gesture

In iPhone App How to implement shake gesture?

Please Help and suggest.

Thanks

Upvotes: 2

Views: 3474

Answers (3)

Tibidabo
Tibidabo

Reputation: 21571

If your ViewController enable first responder

[self becomeFirstResponder]

and implement motionEnded:withEvent:

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

Upvotes: 2

Ved
Ved

Reputation: 612

Find it here How do I detect when someone shakes an iPhone?

Upvotes: 1

Wolfram
Wolfram

Reputation: 8052

Look at the docs to UIResponder and the UIEventSubtypeMotionShake event (from this answer to another SO question).

Upvotes: 0

Related Questions