用一个UILabel配合显示UISlider的数值,在IB中拖入一个UILabel和一个UISlider,设置UISlider的最小值是0,最大值是100,当前值是50,continuous属性为YES。在滑动时按住滑块的瞬间滑块会跳跃一小段,而不是从上一次滑块停止的位置开始,请问是什么原因,该如何解决?
#import "ViewController.h"
@interface ViewController ()
@property (weak, nonatomic) IBOutlet UILabel *sliderLabel;
@end
@implementation ViewController
- (void)viewDidLoad {
[super viewDidLoad];
self.sliderLabel.text = @"50";
}
- (IBAction)sliderChanged:(UISlider *)sender {
int progress = (int)lroundf(sender.value);
self.sliderLabel.text = [NSString stringWithFormat:@"%d", progress];
}
@end