Kyle Rosenbluth
Kyle Rosenbluth

Reputation: 1682

iPhone detect that user moved up their device

I am working on an app where the user sets something (not important what it is) and then puts the phone down. After a little while, the user will pick the phone up again. I want to detect when the user picked up the phone. I am not very experienced with using the accelerometer. I tried to use the accelerometer a little bit but I noticed that I would have a problem because I am looking for movement, which is change from one position to another. If anybody knows how to do this, it would be greatly appreciated.

Thanks,

Upvotes: 1

Views: 1865

Answers (1)

Mick MacCallum
Mick MacCallum

Reputation: 130183

You could try something like this, to fire you action when the accelerometers acceleration equals a value you specify.

- (void)accelerometer:(UIAccelerometer *)accelerometer didAccelerate:(UIAcceleration *)acceleration
{
     if(acceleration.y > 1.0f)
     {
         NSLog(@"acceleration > myValue");
     } 
}

This post may help you as well

Upvotes: 3

Related Questions