tags:

views:

767

answers:

2

hi i want iphone detect shake gesture only one time .

after iphone had been shaken and html files showed , then i want iphone doesn't detect shake anymore .

here is my code :

- (void)accelerometer:(UIAccelerometer *)accelerometer 
        didAccelerate:(UIAcceleration *)acceleration {
    {
        if (acceleration.x > kAccelerationThreshold 
            || acceleration.y > kAccelerationThreshold
            || acceleration.z > kAccelerationThreshold) {


        }
    }
}
+3  A: 

Remove the delegate:

[UIAccelerometer sharedAccelerometer].delegate = nil;
zaph
Thank you works great :)
Momeks
Would it not be better to stop the accelerometer when you don't need it anymore?
Felix
A: 

To Felix -- not really, since you never really stop the accelerometer, but instead you control if the events are sent to your application.

mobibob