xamarin / Xamarin.Forms

Xamarin.Forms is no longer supported. Migrate your apps to .NET MAUI.
https://aka.ms/xamarin-upgrade
Other
5.62k stars 1.87k forks source link

[Bug] [iOS] Tap gesture invoked even after performing clear() at ContentView #14121

Open saravananmadhesh opened 3 years ago

saravananmadhesh commented 3 years ago

Description

Added tap gesture at code behind with command involving on tap, and dynamically cleared the gesture collection and tap on the content view, still command executed.

Works fine in Android and UWP,

Steps to Reproduce

  1. Add tap gesture for content view at code behind. ``

  2. Clear the gesture, at button clicked.

  3. Added new tapgesture at another button click.

Expected Behavior

Expected command only invoke at once.

Actual Behavior

Command invoked multiple times, based on setting new tapgesture to the content view.

Basic Information

Reproduction Link

TapContentView.zip

Workaround

Not found.

saravananmadhesh commented 3 years ago

Any update for this?

rachelkang commented 3 years ago

Hi, @saravananmadhesh - thanks for submitting this issue. That's certainly very strange behavior and we'll have to investigate further.

I tested your repro and had success using .Remove instead of .Clear. So you can create a public variable for your pTapGestureRecognizer and then add the following code to your GoClearTap method: border.GestureRecognizers.Remove(pTapGestureRecognizer);

Hope this helps! :)