Inside your viewController you have to override the method caneBecomeFirstResponder and answering yes, in viewDidAppear you have to set your viewController (self) to be the first responder. This is the code:
-(void)motionEnded:(UIEventSubtype)motion withEvent:(UIEvent *)event {
if (motion == UIEventSubtypeMotionShake) NSLog(@"Detected a shake");
}
-(BOOL)canBecomeFirstResponder {
return YES;
}
- (void)viewDidAppear:(BOOL)animated {
[super viewDidAppear:animated];
[self becomeFirstResponder];
}