ok so i got this UISwitch that when it is set to ON i would like it that if the user shakes the device... something happens like a label appearing. When it is set to off if you shake the device then nothing happens simple enough not for me though haha here's code:
header:
main file:
header:
Code:
#define kAccelerationThreshold 2.2
#define kUpdateInterval (1.0f/10f)
@interface............{
UISwitch *switch;
UILabel *shookDeviceLabel;
}
@property (nonatomic, retain) IBOutlet UISwitch *switch;
@property (nonatomic, reatain) IBOutlet UILabel *shookDeviceLabel;
-(IBAction)switchChanged:(id)sender;
@end
main file:
Code:
@synthesize switch;
@synthesize shookDeviceLabel;
-(IBAction)switchChanged:(id)sender {
if (switch.on = YES) {
- (void)accelerometer:(UIAccelerometer *)accelerometer
didAccelerate:(UIAcceleration *)acceleration {
if (acceleration.x > kAccelerationThreshold
|| acceleration.y > kAccelerationThreshold
|| acceleration.z > kAccelerationThreshold) {
shookDeviceLabel.hidden = NO;
}
}
//* pretty sure this is all completely wrong but help would be nice.