1

Has anyone had any luck to get motionbegan:withevents: to fire in a view controller? Someone had mentioned that I had to set the view controller to be the first responder but souldn't the event get pushed down the responder chain?

kennytm
  • 510,854
  • 105
  • 1,084
  • 1,005

1 Answers1

0

I have the same problem. This may be because a sub view in your view become first responder from parent view. So If the view contains any element, such as a UITextField, that might become first responder itself, ensure that element resigns first responder at some point. With a UITextField, for example, the UIViewController would need to implement the UITextFieldDelegate protocol, and actually be the delegate. Then, in textFieldShouldReturn:

- (BOOL)textFieldShouldReturn:(UITextField *)theTextField {
    // Hides the keyboard
    [theTextField resignFirstResponder];
    // Returns first responder status to self so that shake events register here
    [self becomeFirstResponder];
    return YES;
}

motionBegan: Not Working

Community
  • 1
  • 1
aminhotob
  • 1,056
  • 14
  • 17