Alex Rivera | Logout

Simple iPhone motion detect

Asked 2011-03-06T23:18:09.757
22

I need to detect when the gyroscope / accelerometer is activated a certain amount. Basically to detect when there is movement of the device. I don't know anything about Core Motion.

Maybe someone can direct me to a starters tutorial or something.

Thanks in advance.

Edit
Report

1 Answer

2

In viewDidAppear, become the first responder:

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

And make sure you can be first responder:

- (BOOL)canBecomeFirstResponder {
    return YES;
}

Then you can implement the motion detection.

- (void)motionEnded:(UIEventSubtype)motion withEvent:(UIEvent *)event
{
    if (event.subtype == UIEventTypeMotion){
        //there was motion
    }
}
answered 2011-03-07T00:13:40.740

Your Answer