From fca20968000cfe3ae014fb0eac39b9917a901abc Mon Sep 17 00:00:00 2001 From: Xavier Schott Date: Sat, 5 Dec 2015 18:41:20 -0800 Subject: [PATCH] Update TGPControlsDemo7 to demonstrate UIControlEvents --- .../Base.lproj/Main.storyboard | 850 +++++++++--------- .../TGPControlsDemo7/ViewController.m | 48 + 2 files changed, 491 insertions(+), 407 deletions(-) diff --git a/TGPControlsDemo7/TGPControlsDemo7/Base.lproj/Main.storyboard b/TGPControlsDemo7/TGPControlsDemo7/Base.lproj/Main.storyboard index 0a0fab4..95bffb8 100644 --- a/TGPControlsDemo7/TGPControlsDemo7/Base.lproj/Main.storyboard +++ b/TGPControlsDemo7/TGPControlsDemo7/Base.lproj/Main.storyboard @@ -1,9 +1,10 @@ - + - + + @@ -18,419 +19,454 @@ - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - + + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + - - - - - - - - + + + + + + + + + + diff --git a/TGPControlsDemo7/TGPControlsDemo7/ViewController.m b/TGPControlsDemo7/TGPControlsDemo7/ViewController.m index 7cf8dba..04cdc04 100644 --- a/TGPControlsDemo7/TGPControlsDemo7/ViewController.m +++ b/TGPControlsDemo7/TGPControlsDemo7/ViewController.m @@ -48,6 +48,9 @@ @property (weak, nonatomic) IBOutlet TGPCamelLabels7 *switch1Camel; @property (weak, nonatomic) IBOutlet TGPCamelLabels7 *switch2Camel; + +@property (weak, nonatomic) IBOutlet UILabel *controlEventsLabel; +@property (weak, nonatomic) IBOutlet TGPDiscreteSlider7 *dualColorSlider; @end @implementation ViewController @@ -65,6 +68,18 @@ self.alphabetSlider.ticksListener = self.alphabetLabels; self.oneTo10Slider.ticksListener = self.oneTo10Labels; self.pictureSlider.ticksListener = self.pictureLabels; + + // UIControlEvents + [self.dualColorSlider addTarget:self action:@selector(touchDown:event:) forControlEvents:UIControlEventTouchDown]; + [self.dualColorSlider addTarget:self action:@selector(touchDownRepeat:event:) forControlEvents:UIControlEventTouchDownRepeat]; + [self.dualColorSlider addTarget:self action:@selector(touchDragInside:event:) forControlEvents:UIControlEventTouchDragInside]; + [self.dualColorSlider addTarget:self action:@selector(touchDragOutside:event:) forControlEvents:UIControlEventTouchDragOutside]; + [self.dualColorSlider addTarget:self action:@selector(touchDragEnter:event:) forControlEvents:UIControlEventTouchDragEnter]; + [self.dualColorSlider addTarget:self action:@selector(touchDragExit:event:) forControlEvents:UIControlEventTouchDragExit]; + [self.dualColorSlider addTarget:self action:@selector(touchUpInside:event:) forControlEvents:UIControlEventTouchUpInside]; + [self.dualColorSlider addTarget:self action:@selector(touchUpOutside:event:) forControlEvents:UIControlEventTouchUpOutside]; + [self.dualColorSlider addTarget:self action:@selector(touchCancel:event:) forControlEvents:UIControlEventTouchCancel]; + [self.dualColorSlider addTarget:self action:@selector(valueChanged:event:) forControlEvents:UIControlEventValueChanged]; } #pragma mark - UISwitch @@ -77,4 +92,37 @@ [self.switch2Camel setValue:((sender.isOn) ? 1 : 0)]; } +#pragma mark - UIControlEvents + +- (void)touchDown:(UIControl *)sender event:(UIEvent *)event { + self.controlEventsLabel.text = @"touchDown"; +} +- (void)touchDownRepeat:(UIControl *)sender event:(UIEvent *)event { + self.controlEventsLabel.text = @"touchDownRepeat"; +} +- (void)touchDragInside:(UIControl *)sender event:(UIEvent *)event { + self.controlEventsLabel.text = @"touchDragInside"; +} +- (void)touchDragOutside:(UIControl *)sender event:(UIEvent *)event { + self.controlEventsLabel.text = @"touchDragOutside"; +} +- (void)touchDragEnter:(UIControl *)sender event:(UIEvent *)event { + self.controlEventsLabel.text = @"touchDragEnter"; +} +- (void)touchDragExit:(UIControl *)sender event:(UIEvent *)event { + self.controlEventsLabel.text = @"touchDragExit"; +} +- (void)touchUpInside:(UIControl *)sender event:(UIEvent *)event { + self.controlEventsLabel.text = @"touchUpInside"; +} +- (void)touchUpOutside:(UIControl *)sender event:(UIEvent *)event { + self.controlEventsLabel.text = @"touchUpOutside"; +} +- (void)touchCancel:(UIControl *)sender event:(UIEvent *)event { + self.controlEventsLabel.text = @"touchCancel"; +} +- (void)valueChanged:(UIControl *)sender event:(UIEvent *)event { + self.controlEventsLabel.text = @"valueChanged"; +} + @end \ No newline at end of file