Forum Xamarin.Forms
We are excited to announce that the Xamarin Forums are moving to the new Microsoft Q&A experience. Q&A is the home for technical questions and answers at across all products at Microsoft now including Xamarin!

We encourage you to head over to Microsoft Q&A for .NET for posting new questions and get involved today.

How do I do repeated pinch gestures on the iOS simulator?

EasyGoingPatEasyGoingPat GBMember ✭✭✭

The multi-touch function on the Xamarin iOS simulator is great but I have bumped into what I hope is a silly (i.e. me being dense) problem. When I do a pinch, the two finger circles obviously have to go closer together. When they get as close as they can go, is there a way to move them apart again so that I can do another pinch gesture?

I have tried switching to Shallow Press and back to Multi-Touch but the circles stay where they were last left.

Answers

  • Y3z1Y3z1 Member ✭✭

    When they get as close as they can go, is there a way to move them apart again so that I can do another pinch gesture?

    If you want to test the multi pinch gesture on ios, try to perform the work on a real device. The iOS simulator can only intelligently imitates up to two fingers.

  • JarvanJarvan Member, Xamarin Team Xamurai
    edited July 30

    When they get as close as they can go, is there a way to move them apart again so that I can do another pinch gesture?

    We cannot add multiple gestures to the screen repeatedly. Because the first gesture will focus the screen, it's unable to opeate the page at that time. Try customizing the gesture effect to make the page view fixed when the pinch gesture is completed.

    Check the code:

    UIPinchGestureRecognizer gestureRecognizer = new UIPinchGestureRecognizer(this, new ObjCRuntime.Selector("PinAction:"));
    ...
    [Export("PinAction:")]
    void PinAction(UIPinchGestureRecognizer recognizer)
    {
        var view = recognizer.View;
        view.Transform = CGAffineTransform.Scale(view.Transform, recognizer.Scale, recognizer.Scale);
    
        recognizer.Scale = 1;
    }
    
  • EasyGoingPatEasyGoingPat GBMember ✭✭✭

    @YelinZh said:
    We cannot add multiple gestures to the screen repeatedly. Because the first gesture will focus the screen, it's unable to opeate the page at that time.

    Couldn't a button be added beside the Touch Mode selector at the bottom of the simulator, that simply moves the two-finger grey circles back to their starting position? Or couldn't they spring back automatically? Wouldn't this be much closer to how pinch works on a real physical device? On a real device, pinch doesn't seem to have any memory as such.

    • Patrick

    PS - I'll give the code a try. Thank you. Just a bit nervous until I have time to investigate, because I don't understand what it's doing.

  • EasyGoingPatEasyGoingPat GBMember ✭✭✭

    @Y3z1 said:

    When they get as close as they can go, is there a way to move them apart again so that I can do another pinch gesture?

    If you want to test the multi pinch gesture on ios, try to perform the work on a real device. The iOS simulator can only intelligently imitates up to two fingers.

    Sorry, maybe I didn't explain clearly. I'm not wanting to simulate more than two fingers. I want to perform repeated pinch gestures with two fingers, removing my fingers between each. How you would use Google Maps or zoom into a photograph, for example.

    • Patrick
  • JarvanJarvan Member, Xamarin Team Xamurai

    How you would use Google Maps or zoom into a photograph, for example.

    When testing the zoom gesture in the map, the screen will not rebound automatically after removing fingers.

  • EasyGoingPatEasyGoingPat GBMember ✭✭✭

    @YelinZh said:

    How you would use Google Maps or zoom into a photograph, for example.

    When testing the zoom gesture in the map, the screen will not rebound automatically after removing fingers.

    Sorry, this is difficult to describe. I didn't mean the map bounces back; in fact, I mean the opposite. You can do a pinch (which scales the map), remove fingers (which leaves the map untouched), then do another pinch (which scales the map more). You can keep doing this until the map hits whatever limit the developer has set.

    The same is true going the opposite way, when moving fingers apart.

    The problem with the grey circles in the simulator is that once they touch or reach the edge of the canvas, there is no way to perform any more pinch//expand gestures. So - to me at least - the circles don't seem to emulate multiple real-life pinch/expand gestures.

  • JarvanJarvan Member, Xamarin Team Xamurai
    edited July 31

    Do you want the effect like below?

    Hold down the Alt key and drag the mouse to zoom in and out. When reaching the edge of the canvas, release the Alt key to re-operate or hold down Alt to release the mouse and click

  • EasyGoingPatEasyGoingPat GBMember ✭✭✭

    @YelinZh said:
    Hold down the Alt key and drag the mouse to zoom in and out. When reaching the edge of the canvas, release the Alt key to re-operate or hold down Alt to release the mouse and click

    I am pretty sure that is exactly what I am looking for but am struggling to figure out exactly how it works. (Maybe I need to spend more time on video games.) As soon as I draw something that has a much wider range and therefore more scope for scaling, I will try it again.

    Thank you! I will mark your response as answer when I have tried with a wider image.

    • Patrick
Sign In or Register to comment.