UISlider值更改时会调用什么? [英] What gets called when a UISlider value changes?

查看:126
本文介绍了UISlider值更改时会调用什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

UISlidervalue更改时是否调用方法?我希望能够基于UISliders值来更新值,但仅当它更改时...

Does a method get called when a UISlider's value changes? I want to be able to update a value based on the UISliders value, but only when it changes...

感谢您的帮助.

推荐答案

在IB中,您可以将IBAction连接到Value Changed event或在代码中添加UIControlEventValueChanged的目标/操作.例如:

In IB, you can hook up an IBAction to the Value Changed event or in code add target/action for UIControlEventValueChanged. For example:

[mySlider addTarget:self action:@selector(sliderValueChanged:) forControlEvents:UIControlEventValueChanged];

- (IBAction)sliderValueChanged:(UISlider *)sender {
    NSLog(@"slider value = %f", sender.value);
}

请注意,如果要在用户为sliding时进行值更改事件,则请确保还设置了slidercontinuous property.另一方面,如果您不希望由于用户sliding而触发事件,并且仅当用户完成滑动后才将其设置为NO(或在IB中取消选中)即可.

Note that if you want the value change events as the user is sliding, then be sure that the slider's continuous property is also set. On the other hand, if you don't want the event to fire as the user is sliding and only when they finish sliding, set continuous to NO (or uncheck in IB).

这篇关于UISlider值更改时会调用什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆