Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 615387
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T18:12:54+00:00 2026-05-13T18:12:54+00:00

after reading some posts about implementing shaking on 3.0, I think I get the

  • 0

after reading some posts about implementing shaking on 3.0, I think I get the idea but I’m not getting any call to the:

motionBegan
motionEnded
motionCancelled

this is an example of what I’ve read:
how to detect and program around shakes for the iphone

I’m sure I’ve added the

[self becomeFirstResponder];

and the

-(BOOL)canBecomeFirstResponder {
NSLog(@"First responder");
return YES;
}

Should I enable a special delegate for those events ?

I understand that those events are controlled by the system, and they are passed to the first responder, and go on …

any idea ?

thanks,

r.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-13T18:12:54+00:00Added an answer on May 13, 2026 at 6:12 pm

    I had loads of problems getting this to work and I finally gave up and followed jandrea’s advice. He suggested subclassing UIWindow and implement the motionEnded there. This is a quote from his post here, look for it quite far down.

    First, I subclassed UIWindow. This is
    easy peasy. Create a new class file
    with an interface such as MotionWindow
    : UIWindow (feel free to pick your
    own, natch). Add a method like so:

    - (void)motionEnded:(UIEventSubtype)motion withEvent:(UIEvent *)event {
        if (event.type == UIEventTypeMotion && event.subtype == UIEventSubtypeMotionShake) {
            [[NSNotificationCenter defaultCenter] postNotificationName:@"DeviceShaken" object:self];
        }
    }
    

    Change @”DeviceShaken” to the
    notification name of your choice. Save
    the file.

    Now, if you use a MainWindow.xib
    (stock Xcode template stuff), go in
    there and change the class of your
    Window object from UIWindow to
    MotionWindow or whatever you called
    it. Save the xib. If you set up
    UIWindow programmatically, use your
    new Window class there instead.

    Now your app is using the specialized
    UIWindow class. Wherever you want to
    be told about a shake, sign up for
    them notifications! Like this:

    [[NSNotificationCenter defaultCenter] addObserver:self
    selector:@selector(deviceShaken) name:@"DeviceShaken" object:nil];
    

    To remove yourself as an observer:

    [[NSNotificationCenter defaultCenter] removeObserver:self];
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I was reading some posts about closures and saw this everywhere, but there is
I think this has been done many times before but despite reading some posts
After reading some material on this subject I'm still not sure what the difference
After reading some articles about XSS I have incorporated HTMLPurifier into my zend framework
I came across couple of questions about OCL expressions. After reading some university slides
I am trying to get into android development, after some reading i have settled
After reading some posts like this one: Choose File Dialog It appears that Android
After reading some posts here on the advantages of using source control for a
After spending some hours reading about Unit Testing and test driven development here on
After reading some interesting posts here on SO, and many pages found on google,

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.