简体   繁体   English

如何让用户看到UISlider的值?

[英]How do I let the user see the value of a UISlider?

I added a UISlider in interface builder in my iOS application. 我在iOS应用程序的界面构建器中添加了一个UISlider。 Can I make it so that the user can see the value of a UISlider while he/she is altering it? 我可以制作它,以便用户在改变时可以看到UISlider的值吗?

Is there an interface builder setting I can change to easily implement this, or must I implement an IBAction that alters a UILabel on the screen based on the slider's value? 是否有一个界面构建器设置我可以更改以轻松实现此功能,或者我是否必须实现一个IBAction,它会根据滑块的值改变屏幕上的UILabel?

UISlidervalueChanged选择器连接到自定义IBAction并在该方法中设置一些UILabel的值

Yes there is. 就在这里。 You can set an outlet of type 您可以设置类型的插座

    IBOutlet UISlider *slider

in your view controller, then bind it to the slider. 在视图控制器中,然后将其绑定到滑块。 Then the value of the slider is always accessible through the slider.value property, even in other methods. 然后,即使在其他方法中,也可以通过slider.value属性访问滑块的值。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM