Question

I've added a floatElement to a root section, but when running the app, it seems that the slider is kind of unresponsive. I have to press multiple times to move the slider.

RootElement root = new RootElement (title) 
{
    new Section("Weight") 
    {
        new FloatElement(null, null, 0.5f);
    }
};

The problem is both on my physical device and in the simulator - both running iOS 7.

Any clues?

Was it helpful?

Solution

Ok, I've got a solution (of sorts). I created my own FloatElement (using the Monodialog source from github) and used my own slider inside it. I borrowed a tip from here

http://www.mpatric.com/2009-04-15-more-responsive-sliders-on-the-iphone

to come up with this, which works, but does feel a bit hacky. Not sure why the behaviour has changed in iOS7 though.

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));
    }
} 
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top