Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
krishnakongara opened this issue Jul 21, 2017 · 0 comments

Comments

@krishnakongara
Copy link

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
Projects
None yet
Development

No branches or pull requests

2 participants