本文介绍了iOS7与iOS6中的UISlider行为的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我注意到iOS7中的UISlider与iOS 6和iOS 5中的UISlider行为不同:

I noticed that UISlider in iOS7 behaves differently than it did in iOS 6 and iOS 5:

假设你有一个min = 0和max = 10的滑块,当前值为0.当您第一次触摸旋钮时,将发送一个valueChanged消息,其中slider.value = 0.269(而不是预期的0),旋钮向中间移动。通常,触摸滑块将其移向中间值(在此示例中为5),距离当前中间值越远,移动的越多。

Say you have a slider with min=0 and max=10, current value is 0. When you first touch the "knob", a valueChanged message is sent with slider.value=0.269 (instead of the expected 0) and the knob moves towards the middle. Generally, touching the slider moves it towards the middle value (5 in this example), the farther out from the middle it currently is, the more it moves.

所有这些在iOS6中没有发生,我想恢复旧的行为,但不知道如何实现这一点。

All this did not happen in iOS6, and I'd like to restore the old behaviour, but have no idea how to achieve this.

推荐答案

Apple尚未对我的错误报告发表评论,但我偶然发现了一个或多或少的解决方案:为旋钮安装自定义图像可以恢复iOS 6中的行为:

Apple has not commented on my bug report yet, but I've found a solution more or less by accident: installing a custom image for the knob restores the behaviour from iOS 6:

[self.slider setThumbImage:[UIImage imageNamed:@"knob"] forState:UIControlStateNormal];

这篇关于iOS7与iOS6中的UISlider行为的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-02 07:15