How to detect iphone shake gesture one time !

2019-06-06 00:26发布

问题:

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) {


        }
    }
}

回答1:

Remove the delegate:

[UIAccelerometer sharedAccelerometer].delegate = nil;


标签: iphone shake