现在,当我移动滑块时,我的文本字段的值正在改变。我也需要向后工作,改变文本字段值,滑块移动。
我的代码:
- (void)sliderChanged:(UISlider *)sender {
self.slider.valueChangedHandler = ^(id sender) {
self.aleField.text = [NSString stringWithFormat:@"%.f", [(UISlider *)sender value]];
};
}
编辑
- (BOOL)textField:(UITextField *)textField shouldChangeCharactersInRange:(NSRange)range replacementString:(NSString *)string
{
slider.value = [aleField.text floatValue];
NSUInteger newLength = [aleField.text length] + [string length] - range.length;
return (newLength > 2) ? NO : YES;
}