What is the best approach to changing view properties due to accelerometer changes?
I want to do this: if the device moves (accelerometer values change), then I want to adjust some values in my view according to this movement.
I would like to call a method every time the accelerometer value changes? I think this would be a bad idea as they might be updated too often.
source to share
When you implement the method accelerometer:didAccelerate:
in UIAccelerometerDelegate
, just specify a statement if
, checking if there is enough time between the last time you received the update, long enough.
In your class that implements UIAccelerometerDelegate
, you can have a property that contains something like lastTimeUpdated
, and then update it whenever you change the view
source to share