用一个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
阿神2017-04-18 09:20:52
If possible, it is best to take a screenshot to better observe the phenomenon.
天蓬老师2017-04-18 09:20:52
You are binding the event of the slider. The event must be bound to the team, otherwise problems will occur.