From 3af2a3fa4f9c2ebcaa9acca3c980288f5cc41690 Mon Sep 17 00:00:00 2001 From: Xavier Schott Date: Thu, 12 Mar 2015 15:27:06 -0700 Subject: [PATCH] Fixed #9 - Automatically update the Camels when Slider changes --- TGPControls/TGPCamelLabels7.m | 7 ++++++- TGPControls/TGPControlsTicksProtocol.h | 6 +++++- TGPControls/TGPDiscreteSlider7.m | 7 +++++-- 3 files changed, 16 insertions(+), 4 deletions(-) diff --git a/TGPControls/TGPCamelLabels7.m b/TGPControls/TGPCamelLabels7.m index aa055bd..eb17b4e 100644 --- a/TGPControls/TGPCamelLabels7.m +++ b/TGPControls/TGPCamelLabels7.m @@ -294,8 +294,13 @@ #pragma mark - TGPControlsTicksProtocol --(void)tgpTicksDistanceChanged:(CGFloat)ticksDistance sender:(id)sender +- (void)tgpTicksDistanceChanged:(CGFloat)ticksDistance sender:(id)sender { self.ticksDistance = ticksDistance; } + +- (void)tgpValueChanged:(unsigned int)value +{ + self.value = value; +} @end diff --git a/TGPControls/TGPControlsTicksProtocol.h b/TGPControls/TGPControlsTicksProtocol.h index 5ab2767..9675f88 100644 --- a/TGPControls/TGPControlsTicksProtocol.h +++ b/TGPControls/TGPControlsTicksProtocol.h @@ -29,6 +29,10 @@ // THE SOFTWARE. @protocol TGPControlsTicksProtocol + @required --(void)tgpTicksDistanceChanged:(CGFloat)ticksDistance sender:(id)sender; +- (void)tgpTicksDistanceChanged:(CGFloat)ticksDistance sender:(id)sender; + +@optional +- (void)tgpValueChanged:(unsigned int)value; @end diff --git a/TGPControls/TGPDiscreteSlider7.m b/TGPControls/TGPDiscreteSlider7.m index 8d5973f..420f2cb 100644 --- a/TGPControls/TGPDiscreteSlider7.m +++ b/TGPControls/TGPDiscreteSlider7.m @@ -180,6 +180,11 @@ static CGSize iosThumbShadowOffset = (CGSize){0, 3}; } - (void)sendActionsForControlEvents { + // Automatic UIControlEventValueChanged notification + if([self.ticksListener respondsToSelector:@selector(tgpValueChanged:)]) { + [self.ticksListener tgpValueChanged:self.value]; + } + // Interface builder hides the IBInspectable for UIControl #if !TARGET_INTERFACE_BUILDER [self sendActionsForControlEvents:UIControlEventValueChanged]; @@ -457,8 +462,6 @@ static CGSize iosThumbShadowOffset = (CGSize){0, 3}; - (CGSize)thumbSizeIncludingShadow { switch (self.thumbStyle) { case ComponentStyleInvisible: - return CGSizeZero; - case ComponentStyleRectangular: case ComponentStyleRounded: return ((self.thumbShadowRadius != 0.0)