当我滚动UISlider时,我想在UITextField中显示当前值,但是我看到以下字符串nan
而不是滑块的数值,你能帮我吗:
- (IBAction)sliderValueChanged:(id)sender
{
nomDeStationTextField.text = [NSString stringWithFormat:@"%.1f", [sender value]];
}
IB中的连接是正确的,滑块的最小值是0.0,最大值是70,我需要在UItextField中显示当前位置(即:20)
答案 0 :(得分:2)
将发件人投射到UISlider:
nomDeStationTextField.text = [NSString stringWithFormat:@"%.1f", [(UISlider *)sender value]];