如何在NSSlider上完成动作?

时间:2019-06-20 05:21:26

标签: objective-c macos

有一个NSSlider,其代码如下

- (IBAction)sliderChanged:(id)sender {
NSSlider *slider = sender;
NSInteger value = slider.integerValue;
NSLog(@"%ld",value);
}

因为我设置了slider.continuous = YES;,所以NSLog会实时打印,这是正确的,我需要添加更多内容,除了上面的功能,我想在更改完成后获取值, 有任何想法吗?非常感谢。

1 个答案:

答案 0 :(得分:-1)

UISliderUIControl的子类,您可以为事件UIControlEventTouchUpInside添加目标及其动作。 xib 1

- (IBAction)sliderChanged:(id)sender{
UISlider *slider = sender;
NSLog(@"sliderChanged Value = %ld",(long)slider.value);
}

- (IBAction)sliderFinished:(id)sender{
UISlider *slider = sender;
NSLog(@"sliderFinished Value = %ld",(long)slider.value);
}