iOS7 shakeBegan


#1

I’m having issues getting the shakeBegan method to work.

My HypnosisView can and has becomeFirstResponder, but:

- (void)motionBegan:(UIEventSubtype)motion withEvent:(UIEvent *)event {
    NSLog(@"Device was shaken!");
    if(motion == UIEventSubtypeMotionShake) {
        [self setCircleColor:[UIColor redColor]];
    }
}

Does not print out that the Device was shaken. I’ve tested this on my device and simulator.

I read somewhere that some people had luck using motionEnded, but that’s not worked either. I’ve had motions working in an app I was working on (before I started reading your book) and never had issues.

Cheers,
James


#2

Urgh.

I had becomeFirstResponder rather than canBecomeFirstResponder.