Hi every one for some reasons i can't use shake API , so iam using shake device via accelerometer , but i don't why iPhone 4 , iPad do not support this code !!! but works on all devices .. i don't know what's going on ! here is my code :
#define kAccelerationThreshold 2.2
#define kUpdateInterval (1.0f/10.0f)
@interface info : UIViewController <UIAccelerometerDelegate> {
}
@end
~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~
@implementation info
- (void)viewDidLoad {
UIAccelerometer *accel = [UIAccelerometer sharedAccelerometer];
accel.delegate = self;
accel.updateInterval = kUpdateInterval;
[super viewDidLoad];
}
#pragma mark -
- (void)accelerometer:(UIAccelerometer *)accelerometer
didAccelerate:(UIAcceleration *)acceleration {
{
if (acceleration.x > kAccelerationThreshold
|| acceleration.y > kAccelerationThreshold
|| acceleration.z > kAccelerationThreshold) {
//What do you want to do !
self.view.backgroundColor = [UIColor orangeColor];
}
}
}