tags:

views:

262

answers:

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?

A: 

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;
}

http://stackoverflow.com/questions/1342674/motionbegan-not-working

m. h. ameen