Note that there are some explanatory texts on larger screens.

plurals
  1. POmotionEnded getting called multiple times
    text
    copied!<p>I have a UIViewController subclass that I am trying to have handle the shake event when its view is up. </p> <p>Here are the relevant methods I've implemented:</p> <pre><code>- (void)viewDidAppear:(BOOL)animated { [super viewDidAppear:animated]; [self becomeFirstResponder]; } - (void)viewDidDisappear:(BOOL)animated { [self resignFirstResponder]; [super viewDidDisappear:animated]; } - (BOOL)canBecomeFirstResponder { return YES; } - (void)motionEnded:(UIEventSubtype)motion withEvent:(UIEvent *)event { if (motion == UIEventTypeMotion &amp;&amp; event.type == UIEventSubtypeMotionShake) { NSLog(@"%@ motionEnded", [NSDate date]); } if ([super respondsToSelector:@selector(motionEnded:withEvent:)]) { [super motionEnded:motion withEvent:event]; } } </code></pre> <p>You would expect that when I hit ^+Cmd+Z in the iPhone Simulator that it would just log once, but it is consistently logging twice for each event. Below is the result of three "shake" simulations:</p> <p>2009-10-09 20:52:06.216 TestApp[39802:20b] 2009-10-09 20:52:06 -0400 motionEnded<br> 2009-10-09 20:52:06.218 TestApp[39802:20b] 2009-10-09 20:52:06 -0400 motionEnded<br> 2009-10-09 20:52:07.689 TestApp[39802:20b] 2009-10-09 20:52:07 -0400 motionEnded<br> 2009-10-09 20:52:07.690 TestApp[39802:20b] 2009-10-09 20:52:07 -0400 motionEnded<br> 2009-10-09 20:52:08.001 TestApp[39802:20b] 2009-10-09 20:52:08 -0400 motionEnded<br> 2009-10-09 20:52:08.002 TestApp[39802:20b] 2009-10-09 20:52:08 -0400 motionEnded</p> <p>Has anyone seen this and, if so, how did you fix it? I'm using iPhone SDK 3.1 and Xcode Version 3.1.4.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload