• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: getting the shakes
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: getting the shakes


  • Subject: Re: getting the shakes
  • From: Matt Neuburg <email@hidden>
  • Date: Thu, 09 Jun 2011 08:43:28 -0700

On Wed, 01 Jun 2011 13:35:10 +1000, Graham Cox <email@hidden> said:
>In my IOS app, I'm overriding -motionBegan:withEvent: in my view controller, trying to receive shake events. But it's never called (iOS simulator, version 4.3).

Here's some actual working code (copied and pasted from chapter 35 of my book):

- (BOOL) canBecomeFirstResponder {
    return YES;
}

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

- (void)motionEnded:(UIEventSubtype)motion withEvent:(UIEvent *)event {
    NSLog(@"hey, you shook me!");
}

Might try that. Keep in mind that having a text field as first responder complicates the story a little. m.

--
matt neuburg, phd = email@hidden, <http://www.apeth.net/matt/>
A fool + a tool + an autorelease pool = cool!
Programming iOS 4!
http://www.apeth.net/matt/default.html#iosbook_______________________________________________

Cocoa-dev mailing list (email@hidden)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden

  • Prev by Date: Re: Resizing custom subclassed NSTextView
  • Next by Date: KVO, Bindings and Undo inconsistent
  • Previous by thread: Re: Cocoa-dev Digest, Vol 8, Issue 415
  • Next by thread: KVO, Bindings and Undo inconsistent
  • Index(es):
    • Date
    • Thread