title: How to detect shake motion in iPhone
body: <p>On the shake of the iPhone device i want some function to be called, i dont know how to recognize shake so i tried some link and tried this code</p>
  
  <pre>
  - (void)motionBegan:(UIEventSubtype)motion withEvent:(UIEvent *)event
  {
      if(event.type == UIEventSubtypeMotionShake)
      {
          NSLog(@"called");
          [self.view setBackgroundColor:[UIColor greenColor]];
      }
  }
  
  - (BOOL)canBecomeFirstResponder
  { 
  return YES; 
  }
  
  </pre>
  
  <p>But alas no luck so can you please let me know how i can do the same</p>
  
  <p>Thanks and Regards</p>