قالب وردپرس درنا توس
Home / IOS Development / xamarin.forms – Disable parent-custom control gestures in iOS

xamarin.forms – Disable parent-custom control gestures in iOS



I have a custom control "container" to handle movements and a Skiasharp drawable control inside. The function I'm looking for is, in the first step, the user can make the zoom / move the image inside the container, so the movements in the container are disabled and the user can draw in the visible image with his fingers. It used to work months ago, but when it was moved to xamarin 3.x, it started to fail.

This is the code for the container

  public class GestureContainer: ContentView
{
private const double MIN_SCALE = 1;
private const double MAX_SCALE = 4;
private double start scale, current scale;
private double startX, startY;
private double xOffset, yOffset;

private PanGestureRecognizer pan;
private PinchGestureRecognizer pinchGesture;
private TapGestureRecognizer press;

public static readonly BindableProperty GestureOnProperty =
BindableProperty.Create ("GestureOn", typeof (bool), typeof (GestureContainer), defaultValue: true, defaultBindingMode: BindingMode.TwoWay, propertyChanged: GestureOnChanges);

public bool GestureOn
{
few
{
return (bool) GetValue (GestureOnProperty);
}
set
{
SetValue (GestureOnProperty, Value);
}
}


private static void GestureOnChanges (BindableObject bindable, object oldvalue, object newvalue)
{
GestureContainer gestureContainer = bindable as GestureContainer;

if ((bool) newvalue)
gestureContainer.SetGestures ();
else
gestureContainer.GestureRecognizers.Clear ();

}


public GestureContainer ()
{
pinchGesture = New PinchGestureRecognizer ();
pan = new PanGestureRecognizer ();
press = new TapGestureRecognizer {NumberOfTapsRequired = 2};

SetGestures ();

Scale = MIN_SCALE;
TranslationX = TranslationY = 0;
}

Private Void SetGestures ()
{
pinchGesture.PinchUpdated + = OnPinchUpdated;
GestureRecognizers.Add (pinchGesture);

pan.PanUpdated + = OnPanUpdated;
GestureRecognizers.Add (PAN);

Press. Drawn + = OnTapped;
GestureRecognizers.Add (press);
}

private void OnTapped (object sends, EventArgs e)
{
/ ** /
}

void RestoreScaleValues ​​()
{
/ ** /
}

void OnPinchUpdated (object sends, PinchGestureUpdatedEventArgs e)
{
/ ** /
}

void OnPanUpdated (object sends, PanUpdatedEventArgs e)
{
/ ** /
}
}

The part with the "weird" feature is this:

  gestureContainer.GestureRecognizers.Clear ();

When I launch the bind property to false, the method is called, the .Red () is called, but no matter which clip / pan / tap / button still works, and so the drawing does not touch to work properly [1

9659007]

Source link