【发布时间】:2016-06-07 09:43:12
【问题描述】:
我在我的应用程序中使用滑块。我已经完成了所有设置,我面临的唯一问题是我想要滑块值的标签没有更新。看看我的代码。 我有一个按钮,单击时会为滑块设置动画。我无法更新我的标签,因为它在整个动画中显示为 0.0。 任何帮助将不胜感激。
- (IBAction)btnClicked:(id)sender
{
[UIView animateWithDuration:10 animations:^{
[self.slider setValue:0.0 animated:true];
} completion:^(BOOL finished) {
[UIView animateWithDuration:10 animations:^{
[self.slider setValue:100.0 animated:true];
}];
}];
}
【问题讨论】:
-
您是否将滑块值设置为标签文本?
-
标签的文字在哪里设置?
-
yes ... in - (IBAction)sliderChanged:(id)sender { if (sender == self.slider) { self.lblSliderValue.text = [NSString stringWithFormat:@"%0.0f" , self.slider.value];这仅适用于我手动移动滑块@Bluewings
-
你确定
sliderChanged:方法会在你为滑块设置动画时被调用吗? -
label.text = [NSString stringWithFormat:@"%0.2f", self.slider.value];
标签: ios objective-c cocoa-touch uislider