Quantcast
Channel: Xamarin.Forms — Xamarin Community Forums
Viewing all articles
Browse latest Browse all 91519

How to block UI after tap gesture is tapped

$
0
0

Hi all, my question is this. In forms, how do I get it so that a tap gesture recognizer will only allow itself to be tapped once? The specific problem i'm having is this; I have a couple of images that have tap gestures on them to push a page onto the navigation stack. However if I tap the image really fast before the push occurs it pushes 2 pages onto the stack. I have tried a couple different approaches to preventing this. One approach is using the ACR user dialogs library. In this instance as soon as the tapped event hits, I do a

using(UserDialogs.Instance.Loading("Loading"){
    MyPage page = new MyPage();
    await Navigation.PushAsync(page);
}

but the using code doesn't hit in enough time and still allows the second quick tap to be recognized and still pushes 2 pages onto the stack

I've also tried a simple time comparison and that doesn't work either. For example

if(lastTapped.AddMilliseconds(10) < DateTime.Now)
{
   lastTapped = DateTime.Now;
   // Push page
}

and this doesn't work either because similar to the previous example, the code to set lastTapped = DateTime.Now doesn't execute before the second tap is recognized.

Help, this problem is driving me crazy!


Viewing all articles
Browse latest Browse all 91519

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>