Quantcast
Channel: Xamarin.Forms — Xamarin Community Forums
Viewing all articles
Browse latest Browse all 91519

Swipe Gesture on Relative Layout

$
0
0

have a Xamarin App which I am trying to add swipe gesture recogniser to a Relative Layout via Custom Renderer.

public class MainPageCarouselRenderer : VisualElementRenderer<RelativeLayout>
{
    UISwipeGestureRecognizer asd;
    UISwipeGestureRecognizer asd2;

    protected override void OnElementChanged (ElementChangedEventArgs<RelativeLayout> e)
    {
        base.OnElementChanged (e);

        asd = new UISwipeGestureRecognizer (() => {
            e.NewElement.TranslateTo (0, -150, 500, Easing.BounceOut);
        });

        asd.Direction = UISwipeGestureRecognizerDirection.Up;
        asd2 = new UISwipeGestureRecognizer (() => {

            e.NewElement.TranslateTo (0, 0, 500, Easing.BounceOut);
        });

        asd2.Direction = UISwipeGestureRecognizerDirection.Down;
        this.AddGestureRecognizer (asd);
        this.AddGestureRecognizer (asd2);
    }



}

this is the code in my IOS Renderer. I debugged this piece of code and breakpoint that I put here got hit. But when I put breakpoint inside the

            asd2 = new UISwipeGestureRecognizer (() => {

            e.NewElement.TranslateTo (0, 0, 500, Easing.BounceOut);
        });

or the other one it doesn't get hit. Any ideas?


Viewing all articles
Browse latest Browse all 91519

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>