Skip to content

Commit

Permalink
Fix crash with max count.
Browse files Browse the repository at this point in the history
  • Loading branch information
spromicky committed Jan 18, 2017
1 parent fa6f175 commit dd1825a
Showing 1 changed file with 14 additions and 5 deletions.
19 changes: 14 additions & 5 deletions StepSlider/source/StepSlider/StepSlider.m
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,7 @@ - (void)generalSetup
_sliderCircleColor = [UIColor whiteColor];
_labelOffset = 20.f;
_labelColor = [UIColor whiteColor];
[self updateMaxRadius];

[self setNeedsLayout];
}
Expand Down Expand Up @@ -508,16 +509,24 @@ - (void)setLabels:(NSArray<NSString *> *)labels
_labels = labels;

if (_labels.count > 0) {
self.maxCount = _labels.count;
} else {
[self updateIndex];
[self setNeedsLayout];
_maxCount = _labels.count;
}

[self updateIndex];
[self setNeedsLayout];
}
}

- (void)setMaxCount:(NSUInteger)maxCount
{
if (_maxCount != maxCount && !self.labels.count) {
_maxCount = maxCount;
[self updateIndex];
[self setNeedsLayout];
}
}

GENERATE_SETTER(index, NSUInteger, setIndex, [self updateIndex]; [self sendActionsForControlEvents:UIControlEventValueChanged];);
GENERATE_SETTER(maxCount, NSUInteger, setMaxCount, [self updateIndex];);

GENERATE_SETTER(trackHeight, CGFloat, setTrackHeight, [self updateDiff];);
GENERATE_SETTER(trackCircleRadius, CGFloat, setTrackCircleRadius, [self updateDiff]; [self updateMaxRadius];);
Expand Down

0 comments on commit dd1825a

Please sign in to comment.