Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Swipe Up/Down gestures working fine with iOS emulator but not on actual device #29

Open
ghost opened this issue Dec 30, 2015 · 4 comments

Comments

@ghost
Copy link

ghost commented Dec 30, 2015

Swipe up/down working fine with iOS 9.1 and 9.2 (iPhone 5S emulator). When I tried on an actual device (iPhone 5S running iOS 9.2) my app would crash.

System.MissingMethodException: Constructor on type 'UIKit.UISwipeGestureRecognizer' not found.

I can post the full stack trace if required. The app wouldn't crash when trying to swipe up or down, it was before, when configuring the gesture recognisers, with this code:

            SwipeGestureRecognizer LeftSwipeUpGestureRecognizer = new SwipeGestureRecognizer();
            LeftSwipeUpGestureRecognizer.Direction = SwipeGestureRecognizerDirection.Up;
            LeftSwipeUpGestureRecognizer.OnAction += (s, e) => HandleSwipeUp(SlidesArray, BubblesArray);
            LeftStackLayout.GestureRecognizers.Add(LeftSwipeUpGestureRecognizer);

            SwipeGestureRecognizer LeftSwipeDownGestureRecognizer = new SwipeGestureRecognizer();
            LeftSwipeDownGestureRecognizer.Direction = SwipeGestureRecognizerDirection.Down;
            LeftSwipeDownGestureRecognizer.OnAction += (s, e) => HandleSwipeDown(SlidesArray, BubblesArray);
            LeftStackLayout.GestureRecognizers.Add(LeftSwipeDownGestureRecognizer);
            LeftStackLayout.ProcessGestureRecognizers(); // This does both up and down.

I.e. commenting that code out to ignore the swipe up/down would stop the app from crashing.

Is this something you or anyone has seen before?

Thanks

@ghost
Copy link
Author

ghost commented Jan 4, 2016

Actually, having just downloaded a fresh copy of the code from this repo, it doesn't work correctly on my iPad.

The app loads ok but most (if not all) pages appear blank, i.e. when I tap "Swipe" to test the swiping features I am presented with a blank screen.

The iPad is running iOS 9.2.

Again, however, the emulator runs perfectly with no issues and swipe gestures work correctly. And that's iOS 9.2 too.

Cheers

@ckogevina
Copy link

I think this is a Xamarin bug similar to this mentioned here: https://bugzilla.xamarin.com/show_bug.cgi?id=37563
You can bypass it if you set linker behavior: Don't link

@rohitvipin
Copy link

run into it and only suggested approach is dont link?

@rohitvipin
Copy link

rohitvipin commented Nov 7, 2017

To ensure linker does not remove your Gestures add the following to your AppDelegate FinishedLaunching method

    /// <summary>
    /// To ensure gestures not getting stripped out in linking. 
    /// </summary>
    private static void InitializeGestures()
    {
        GestureRecognizerExtensions.Factory = new NativeGestureRecognizerFactory();
        var uiSwipeGestureRecognizer = new UISwipeGestureRecognizer(() => { });
        var nativeSwipeGestureRecognizer = new NativeSwipeGestureRecognizer();
        var uiSwipeGestureRecognizer2 = new UISwipeGestureRecognizer(nativeSwipeGestureRecognizer2 => { });
        var uiSwipeGestureRecognizer3 = new UISwipeGestureRecognizer();
    }

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants