Hi everyone . iam trying to shake device with Accelerometer (NOT SHAKE API) because i have a problem with shake api . but idon't know why my code doesn't work on iPad !!! :
viewDidLoad:
[[UIAccelerometer sharedAccelerometer] setUpdateInterval:(1.0 / 40)];
[[UIAccelerometer sharedAccelerometer] setDelegate:self];
As a method :
- (void)accelerometer:(UIAccelerometer *)accelerometer didAccelerate:(UIAcceleration *)acceleration {
const float violence = 1.5;
static BOOL beenhere;
BOOL shake = FALSE;
if (beenhere) return;
beenhere = TRUE;
if (acceleration.x > violence * 1.5 || acceleration.x < (-1.5* violence))
shake = TRUE;
if (acceleration.y > violence * 2 || acceleration.y < (-2 * violence))
shake = TRUE;
if (acceleration.z > violence * 3 || acceleration.z < (-3 * violence))
shake = TRUE;
if (shake) {
// YOUR CODE HERE ****
}
beenhere = FALSE;
}
thank you for any help ;)