Skip to content

UILongPressGestureRecognizer & UITapGestureRecognizer don't work just on iPhone 7  #66

Open

Description

@krishnakongara

The UILongPressGesture & UITapGestureRecognizer 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 also made sure it's not an issue of the touch duration or the state of touch.

It is observed that they work when the default PanZoomGestureRecognizer is removed from the PlotView but that will disable the pan and zoom gestures of the plot. This can be seen by uncommenting the commented part of the code below.

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

namespace longpress.iOS
{
  public partial class ViewController : UIViewController
  {
    public ViewController(IntPtr handle) : base(handle)
    {
    }

    public override void ViewDidLoad()
    {
        base.ViewDidLoad();

        var plotView = new PlotView
        {
            Model = CreatePlotModel(),
            Frame = this.View.Frame
        };
        View.AddSubview(plotView);

        //foreach (UIGestureRecognizer recognizer in plotView.GestureRecognizers)
        //{
        //    if (recognizer is PanZoomGestureRecognizer)
        //    {
        //        plotView.RemoveGestureRecognizer(recognizer);
        //    }
        //}

        plotView.AddGestureRecognizer(new UILongPressGestureRecognizer((obj) => { Console.WriteLine("LongPress triggered"); }));
        plotView.AddGestureRecognizer(new UITapGestureRecognizer((obj) => { Console.WriteLine("Tap triggered"); }));
    }

    public override void DidReceiveMemoryWarning()
    {
        base.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));

        plotModel.Series.Add(series1);

        return plotModel;
    }
 }
}

However, there is no explanation as to why this happens on no other device but iPhone 7.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions