0

I am currently working on update 3 to my app, I wanted to add the ability to shake the iPhone and have it go to a random cell in my UITableView. I know Apple recommends against doing this kind of gesture, but I want to add it or at least try it out.

Any help would be appreciated!

rmaddy
  • 314,917
  • 42
  • 532
  • 579

1 Answers1

0

Use this

-(void)motionEnded:(UIEventSubtype)motion withEvent:(UIEvent *)event
{
       if(motion == UIEventSubtypeMotionShake)
       {
          NSLog(@"Shake");
       }
}
-(BOOL)canBecomeFirstResponder
{
    return YES;
}
Durgaprasad
  • 1,910
  • 2
  • 25
  • 44
  • 1
    Need to set view/controller as firstResponder by calling `-becomeFirstResponder` method and also implement `canBecomeFirstResponder` method and return `YES` to respond to shake event. – Amar Jul 02 '13 at 11:40