Forum Cross Platform with Xamarin

TapGestureRecognizer Single and Double on Android and IOS

Hello

I have quite a conundrum. I have controls that have Single and Double tap events. On Android they work flawlessly. But on IOS I can never get the double tap to work because the single tap happens so fast.

I know there has to be a way to handle this, and there has to be someone that has done this.

Any help would be much appreciate. :)

Answers

  • jezhjezh Member, Xamarin Team Xamurai
    edited February 2

    Sorry, I couldn't reproduce this problem on our side.

       <TapGestureRecognizer 
                Tapped="OnTapGestureRecognizerTapped" 
                NumberOfTapsRequired="2" />
    

    Could you please post the code snippets here so that we can help you bettter?


    Xamarin forums are migrating to a new home on Microsoft Q&A!
    We invite you to post new questions in the Xamarin forums’ new home on Microsoft Q&A!
    For more information, please refer to this sticky post.

  • sisaackssisaacks Member ✭✭✭✭
    edited February 3

    @jezh its super easy to replicate, take the code below and run on IOS and see if you an get the double click action to run or run without the single click action happening. I did find a way to do so...but I am not convinced its 100% effective

    <Frame Grid.Column="0" Grid.Row="2" Style="{StaticResource EditableFrame}">
                                        <Frame.GestureRecognizers>
                                            <TapGestureRecognizer Command="{Binding DoSomething}" CommandParameter="{Binding MyParam}" NumberOfTapsRequired="1"/>
                                            <TapGestureRecognizer Command="{Binding DoSomething2}"  NumberOfTapsRequired="2"/>
                                        </Frame.GestureRecognizers>
                                        <StackLayout Orientation="Vertical" Spacing="5">
                                            <Label Text="Hello" Style="{StaticResource DataHintText}"/>
                                            <Label Text="World" Style="{StaticResource DataText}"/>
                                        </StackLayout>
                                    </Frame>
    
  • sisaackssisaacks Member ✭✭✭✭
    edited February 3

    For some reason the code did not show up

     <StackLayout Orientation="Vertical" Spacing="5">
    StackLayout.GestureRecognizers>
                                            <TapGestureRecognizer Command="{Binding GetPickerCommand}" CommandParameter="{Binding WindSpeed1Type}" NumberOfTapsRequired="1"/>
                                            <TapGestureRecognizer Command="{Binding ShowWind1Command}"  NumberOfTapsRequired="2"/>
                                        </StackLayout.GestureRecognizers>
                                            <Label Text="{Binding WindSpeed1HintText}" Style="{StaticResource DataHintText}"/>
                                            <Label Text="{Binding WindSpeed1}" Style="{StaticResource DataText}"/>
                                        </StackLayout>
    
  • sisaackssisaacks Member ✭✭✭✭

    LOL i dont know why its not showing up.
    But to replicate, create a single tap, and double tap gesture recognizer
    Try to get the double tap to work on IOS.....

  • jezhjezh Member, Xamarin Team Xamurai
    <BoxView.GestureRecognizers>
            <TapGestureRecognizer NumberOfTapsRequired="2" Tapped="TapGestureRecognizer_Tapped"/>
            <TapGestureRecognizer NumberOfTapsRequired="1" Tapped="TapGestureRecognizer_Tapped_1"/>
    </BoxView.GestureRecognizers>
    

    I tested above code which is similar to yours,when I click twice in a row,both event TapGestureRecognizer_Tapped and TapGestureRecognizer_Tapped_1 will been triggered not the case never get the double tap you mentioned.

  • sisaackssisaacks Member ✭✭✭✭

    @jezh I can assure you, on IOS, you cannot get the double tap to work without the single tap happening......and more often that not you cant get the double tap to work because the single tap happens. I am not making this up....its very simple....

    <BoxView.GestureRecognizers>


    </BoxView.GestureRecognizers>

  • sisaackssisaacks Member ✭✭✭✭

    I Dont know how you got the code to show up on this? anyway on IOS 10, you cannot get the double tap to work because of the single tap. You can put a delay....but then both are fired. I removed all my code because of this. Super annoying. Each action I have opens popup. Single Tap opens one type and the double tap opened a different type. I would either constantly get the single tap popup or i would get both.

  • jezhjezh Member, Xamarin Team Xamurai

    I tested on emulator IOS 14.4, and I have updated the Visual studio and nuget xamarin form nuget to the latest version.
    You can try it.

  • sisaackssisaacks Member ✭✭✭✭

    I am testing on actual devices not an emulator and I have udpated. Maybe their is a language barrier problem or misunderstanding. If you have a control, that has a single tap that calls a method and a double tap that calls a method...on IOS you cannot get the double tap. Atleast not on the Samsung devices I am testing. I can 100% assure you. I have read multiple places online of people having the same issue and many people saying its not a good idea to do

  • jezhjezh Member, Xamarin Team Xamurai
    edited February 4

    What specific device are you testing on, and what is the version of the device?

    You can try not listening the tapevent in the model. In other words, not use the Command and CommandParameter.

  • sisaackssisaacks Member ✭✭✭✭

    @jezh I am using MVVM....thus I would need a command parameter. It cold be because its on a frame as well. Its an Iphone 11. I will try using methods and see if that makes a difference...though I am using MVVM...but at least I can update on here. I have already removed all the double tap instances on my app.

  • jezhjezh Member, Xamarin Team Xamurai

    Waitting for your good news. :)

Sign In or Register to comment.