Detecting Shakes - HypnosisView not becoming first responder



I’m really enjoying this book although have got myself a little stuck with this section (probably something silly!). I can’t get the color to change with the shake gesture. I’ve worked out that the motionBegin event isn’t being triggered within HypnosisView.
This led me to believe that it’s not actually becoming the firstResponder, which I have confirmed with the following output to console in viewWillAppear in HypnosisViewController:

	[[self view] becomeFirstResponder];
	NSLog(@"Is the view the first responder? %d", [[self view] isFirstResponder]);
	2010-10-20 18:53:27.371 HypnoTime[2156:307] is the view the first responder? 0

I’ve checked that HypnosisView implements the method - (BOOL)canBecomeFirstResponder.

Any ideas on what might be wrong, or what I should be looking for to diagnoise this problem?

Many thanks,



Try putting the log statement in the viewDidAppear method and you should see a 1.

I don’t think that is the issue though.

I notice you’ve referred to the event as motionBegin - but it should be motionBegan - that might be it.



Thanks a lot Gareth, it was indeed due to the misspelling of motionBegan :slight_smile:

Moving the log statement to viewDidAppear now gives me a 1. There’s obviously some stuff happening to determine the responder chain between viewWillAppear and viewDidAppear. I need to learn more about this though.

Anyway, really appreciate the help!


My HypnosisView view becomes First Responder, but the -(BOOL)motionBegan… method is not executed when i shake the phone… What could be a problem?