Hi there,
I'm using this code to do shake detection, and for the most part it works fine:
- (void)motionEnded:(UIEventSubtype)motion withEvent:(UIEvent *)event {
if (event.type == UIEventSubtypeMotionShake) {
if ( event.subtype == UIEventSubtypeMotionShake )
{
NSLog (@"Shake Called");
}
}
I believe for this to work, I also needed to use these, which I have:
- (void)viewDidAppear:(BOOL)animated {
[super viewDidAppear:animated];
[self becomeFirstResponder];
}
- (void)viewDidDisappear:(BOOL)animated {
[self resignFirstResponder];
[super viewDidDisappear:animated];
}
This all works great, and motionEnded is called every time I shake, until I click through a link in a webView on my program. I can scroll up and down in the view and shake still works, but as soon as the view loads a new page, motionEnded stops being called when I shake. This occurs both in the simulator and on a real device (iPhone 3G, iOS4). From my limited understanding, I believe it has something to do with first responders, but I could be wrong there!
Any ideas interweb people?
Thanks,
Joe