Click here to Skip to main content
15,888,984 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
I tried to implement Swipe tabbed render but there is also have an issue. Left side swipe does not work properly.

What I have tried:

[assembly: ExportRenderer(typeof(TabbedPage), typeof(SwipeTabbedRenderer))]

class SwipeTabbedRenderer : TabbedRenderer
{
    public override void ViewWillAppear(bool animated)
    {
        base.ViewWillAppear(animated);

        NativeView.AddGestureRecognizer(new UISwipeGestureRecognizer(() => SelectNextTab(1)) 
{ Direction = UISwipeGestureRecognizerDirection.Left, 
ShouldRecognizeSimultaneously = ShouldRecognizeSimultaneously 
});
       
 NativeView.AddGestureRecognizer(new UISwipeGestureRecognizer(() => SelectNextTab(-1)) 
{ 
 Direction = UISwipeGestureRecognizerDirection.Right, 
ShouldRecognizeSimultaneously = ShouldRecognizeSimultaneously 
});
    }

    void SelectNextTab(int direction)
    {
        int nextIndex = TabbedPage.GetIndex(Tabbed.CurrentPage) + direction;
        if (nextIndex < 0 || nextIndex >= Tabbed.Children.Count) return;
        var nextPage = Tabbed.Children[nextIndex];
        UIView.Transition(Platform.GetRenderer(Tabbed.CurrentPage).NativeView, Platform.GetRenderer(nextPage).NativeView, 0.15, UIViewAnimationOptions.TransitionCrossDissolve, null);
        Tabbed.CurrentPage = nextPage;
    }

    static bool ShouldRecognizeSimultaneously(UIGestureRecognizer gestureRecognizer, UIGestureRecognizer otherGestureRecognizer) => gestureRecognizer != otherGestureRecognizer;
}
Posted
Updated 23-Mar-18 11:52am
Comments
David Crow 23-Mar-18 10:14am    
"Left side swipe does not work properly."

And that means what exactly?

1 solution

set a breakpoint on your gesture recognizer for the left swipes and my guess is you will find that it is replacing the normal left swipe.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900