Forum Xamarin.iOS

UILongPressGestureRecognizer for an oxyplot doesn't work just on iPhone 7

KrishnaKongaraKrishnaKongara USMember
edited July 2017 in Xamarin.iOS

The UILongPressGesture won't be triggered on Oxyplot (PlotView) in iPhone 7 (iOS 10.3.2) though it works on all other iOS devices and even on iPhone 7 simulator.

I made sure that it's not a problem of the press duration or the state of the recognizer. Since it's a plot it could be that it's conflicting with other gesture listeners but that doesn't explain why it works perfectly on other iOS devices with the same OS version.

Here is the code (you need to add OxyPlot.Core & OxyPlot.Xamarin.iOS to your packages)

using System;
using CoreGraphics;
using OxyPlot;
using OxyPlot.Axes;
using OxyPlot.Series;
using OxyPlot.Xamarin.iOS;
using UIKit;

namespace longpress.iOS
    public partial class ViewController : UIViewController
        UILongPressGestureRecognizer pressRecognizer;

        public ViewController(IntPtr handle) : base(handle)

        public override void ViewDidLoad()

            pressRecognizer = new UILongPressGestureRecognizer();
            pressRecognizer.AddTarget(() => HandleLongPress(pressRecognizer));

            var plotView = new PlotView
            Model = CreatePlotModel(),
            Frame = this.View.Frame

            plotView.UserInteractionEnabled = true;

        public override void DidReceiveMemoryWarning()
            // Release any cached data, images, etc that aren't in use.

        private PlotModel CreatePlotModel()
            var plotModel = new PlotModel { Title = "OxyPlot Demo" };
            plotModel.Axes.Add(new LinearAxis { Position = AxisPosition.Bottom });
            plotModel.Axes.Add(new LinearAxis { Position = AxisPosition.Left, Maximum = 10, Minimum = 0 });
            var series1 = new LineSeries
                MarkerType = MarkerType.Circle,
                MarkerSize = 4,
                MarkerStroke = OxyColors.White
            series1.Points.Add(new DataPoint(0.0, 6.0));
            series1.Points.Add(new DataPoint(1.4, 2.1));
            series1.Points.Add(new DataPoint(2.0, 4.2));
            series1.Points.Add(new DataPoint(3.3, 2.3));
            series1.Points.Add(new DataPoint(4.7, 7.4));
            series1.Points.Add(new DataPoint(6.0, 6.2));
            series1.Points.Add(new DataPoint(8.9, 8.9));
            return plotModel;

        public void HandleLongPress(UILongPressGestureRecognizer longPress)
            Console.WriteLine("LongPress triggered");

Steps to reproduce: Just debug the application on an iPhone 7

Expected behaviour: LongPress Triggered should be printed in the console

Actual behaviour: The listener/recognizer is never triggered and so the line is never printed


  • KrishnaKongaraKrishnaKongara USMember

    Also, the UITapGestureRecognizer won't work. However, they work if the default PanZoomGestureRecognizer is removed from the PlotView but then the pan and zoom are disabled.

Sign In or Register to comment.