I am searching for a good and fluid way to move multiple UIViews over the Screen at once. The Action should happen when the Accelerometer detects acceleration. I have already tried this way:
- (void)accelerometer:(UIAccelerometer *)accelerometer didAccelerate:(UIAcceleration *)acceleration{
CGPoint ObjectPos = Object.center;
ObjectPos.x -= acceleration.x;
Object.center = ObjectPos;
}
(of course I added some tweaking to improve the movement detection), but all in all, it still is not very fluid.
I hoped there is some way with core animation, but it does not seem to work with the acceleration pretty well.
Help is really appreciated, thanks!
I advise you to read this piece of documentation:
Isolating the Gravity Component from Acceleration Dataand the section below that called ‘Isolating Instantaneous Motion from Acceleration Data’.Basically, you need to filter out gravity in order to get smooth movement. The link provides sample-code.
Edit: UIAccelerometer was deprecated in iOS 5.0, and the accompanying documentation seems to be gone as well.
For future reference I did some digging and found, what seems to be, a ‘carbon copy’ of the original sample code (source):