Take the 2-minute tour ×

I have this inside my viewcontroller.m

- (void)motionEnded:(UIEventSubtype)motion withEvent:(UIEvent *)event {
    if (event.type == UIEventSubtypeMotionShake) {

    NSLog(@"shake shake shake");


- (void)viewDidLoad
    [self performSelector:@selector(becomeFirstResponder) withObject:nil afterDelay:0.3];

But when I shake my phone nothing happens. Why?

share|improve this question

1 Answer 1

up vote 1 down vote accepted

I had the same problem and I'm not sure what is the reason for it. However, I have a solution.. When I call [self becomeFirstResponder] in the viewDidAppear method, the shake detection works.

- (void) viewDidAppear:(BOOL)animated{
    [super viewDidAppear:animated];
    [self becomeFirstResponder];

I hope this helps.

share|improve this answer

Your Answer


