这就是我目前的做法
- (IBAction)sliderDistanceChanged {
CGFloat sliderPosition = self.sliderDistance.value;
NSUInteger sliderIndex = [BGDistanceFilterStop indexForFilterEffect:sliderPosition];
self.distanceFilterForCatalog = @([BGDistanceFilterStop numberValueOfDistance:sliderIndex]);
//self.distanceFilterForCatalog= @(self.sliderDistance.value).roundWithForDistanceFilter;
//[self.distanceFilter setTitle:self.distanceFilterForCatalog.distanceForm forState:UIControlStateNormal];
[self.distanceFilter setTitle:[BGDistanceFilterStop stringValueOfDistance:sliderIndex] forState:UIControlStateNormal];
}
- (IBAction)SliderNoLongerTouched:(id)sender {
CGFloat sliderIndex = [BGDistanceFilterStop sliderSnappedPosition:self.sliderDistance.value];
self.sliderDistance.value=sliderIndex;
}
基本上它会检测 self.sliderDistance.value ,然后根据它在舍入后设置报告的值。
一旦用户不再触摸,我改变 self.sliderDistance.value 的位置
没事儿。
但是,我想在用户修改之前更改 self.sliderDistance.value。但是,它与 iOS 用于跟踪手的位置和滑块值的变量相同。
那么如何在不更改 self.sliderDistance.value 的情况下安排按钮捕捉到正确的位置?