Closed codwam closed 8 years ago
Hi!
If you look at ViewController.m
in the sample project you'll find a simple way to do so:
[starRatingView addTarget:self action:@selector(didChangeValue:) forControlEvents:UIControlEventValueChanged];
Then all you have to do is implement something like
- (IBAction)didChangeValue:(HCSStarRatingView *)sender {
NSLog(@"Changed rating to %.1f", sender.value);
}
You should also be able to use KVO to observe the value
property.
[starRatingView addObserver:self forKeyPath:@"value" options:NSKeyValueObservingOptionNew | NSKeyValueObservingOptionOld context:nil];
Above is no effect... Is there should be notify value will changed?
[self willChangeValueForKey:@"value"];
_value = value;
[self didChangeValueForKey:@"value"];
if (sendAction) [self sendActionsForControlEvents:UIControlEventValueChanged];
[self setNeedsDisplay];
How to observe value changed?