我已经向根部分添加了一个floatElement,但是在运行应用程序时,滑块似乎没有响应。我必须按多次才能移动滑块。
RootElement root = new RootElement (title)
{
new Section("Weight")
{
new FloatElement(null, null, 0.5f);
}
};
问题出现在我的物理设备和模拟器中 - 都运行iOS 7。
任何线索?
答案 0 :(得分:1)
好的,我有一个解决方案(各种各样)。我创建了自己的FloatElement(使用来自github的Monodialog源代码)并在其中使用了我自己的滑块。我从这里借了一个小费
http://www.mpatric.com/2009-04-15-more-responsive-sliders-on-the-iphone
提出这个,这有效,但确实感觉有点hacky。不知道为什么iOS7中的行为发生了变化。
public class Slidy : UISlider
{
private static int THUMB_SIZE = 10;
private static int EFFECTIVE_THUMB_SIZE = 20;
public Slidy(RectangleF r)
: base(r)
{
}
public override bool PointInside(PointF point, UIEvent uievent)
{
var bounds = this.Bounds;
bounds = RectangleF.Inflate(bounds, 25, 25);
return bounds.Contains(point);
}
public override bool BeginTracking(UITouch touch, UIEvent uievent)
{
var bounds = this.Bounds;
float thumbPercent = (this.Value - this.MinValue) / (this.MaxValue - this.MinValue);
float thumbPos = THUMB_SIZE + (thumbPercent * (bounds.Size.Width - (2 * THUMB_SIZE)));
var touchPoint = touch.LocationInView(this);
return (touchPoint.X >= (thumbPos - EFFECTIVE_THUMB_SIZE) &&
touchPoint.X <= (thumbPos + EFFECTIVE_THUMB_SIZE));
}
}