views:

94

answers:

1

Hi,

Is there any way to find, iPhone movement?. I need to know if iPhone is still i.e its not moving then do some thing or else if iPhone is moving(in vertical or horizontal direction) do some logic.

Do I need to read accelerometer didAccelerate method. Or there is some other way like reading current location (lat/log) values.

[I DON'T have 3GS]

Please suggest which is the best and robust way to read iPhone movement and how to know if iPhone is still.

Thanks

+1  A: 

Yes, you will need to use the UIAccelerometer class. Set the delegate and do some calculations on the accelerometer:didAccelerate delegate message.

The trick is that you will want to set up some threshold values. If there is no sig movement within your range in the x, y, and z axis, the device is not moving.

Of course, slight vibrations will cause value changes, which is why you will need to determine what not moving is for your purposes.

bstahlhood
You stole my answer. lol.. Voted up. :)
Chintan Patel