如何给UISlider设置断点?
我有两个名为 slider1
slider1.minimumValue = 0; 的 UISlider slider1.maximumValue = 100;
我想设置一个断点,比如60,如果滑块1从0(左)移动到60(右),它会停在这里,拇指不能向右移动,但可以向左移动。那我该怎么办呢?
请看一下下面的代码,它不起作用,谢谢
-(IBAction)s1valuechanged:(id)sender{
if ((int)slider1.value > 60) {
slider1.userInteractionEnabled = FALSE;
}
else{
slider1.userInteractionEnabled =TRUE;
}
}
I have two UISlider called slider1
slider1.minimumValue = 0; slider1.maximumValue = 100;
i want to set a break point,such as 60, if the slider1 move to 60 from 0(left) to 60(right), it will stop here the thumb can not move to right, but it can move to left. so how can i do?
please take a look the following code, it doesn't work, thanks
-(IBAction)s1valuechanged:(id)sender{
if ((int)slider1.value > 60) {
slider1.userInteractionEnabled = FALSE;
}
else{
slider1.userInteractionEnabled =TRUE;
}
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我在理解你的问题时遇到了一些困难,所以我假设你的滑块如下所示,并且你想阻止用户将滑块移动到大于 60:
0 的值 ---- ------60-----100
|---有效----|-无效-|
您所需要的只是以下内容:
换句话说,每当用户尝试将滑块移动到大于 60 的值时,请将滑块移回到 60。
I'm having a bit of trouble understanding your question, so I'm going to assume that your slider looks like the following, and you want to prevent the user from moving the slider to a value greater than 60:
0 ----------60------100
|---valid----|-invalid-|
All you would need is the following:
In other words, whenever the user tries to move the slider to a value greater than 60, move the slider back to 60.