Hey everyone!
I got a problem with my custom page renderer which adds the SwipeBack Functionality on all Pages. I need this because the NavigationBar on the respective Pages is disabled but I want to have the SwipeBack Functionality. I found this solution in multiple sources but it is not working as expected.
[assembly: Xamarin.Forms.ExportRenderer(typeof(ContentPage), typeof(ContentPageRenderer))] namespace MyApp { public class ContentPageRenderer : PageRenderer { public ContentPage ContentPageElement => Element as ContentPage; public override void ViewWillAppear(bool animated) { base.ViewDidAppear(animated); if (ViewController.NavigationController != null) { ViewController.NavigationController.InteractivePopGestureRecognizer.Enabled = true; ViewController.NavigationController.InteractivePopGestureRecognizer.Delegate = new UIGestureRecognizerDelegate(); ViewController.NavigationController.InteractivePopGestureRecognizer.AddTarget(this, new ObjCRuntime.Selector(nameof(HandleBackSwipe))); } } [Export(nameof(HandleBackSwipe))] private void HandleBackSwipe() { if (ViewController.NavigationController != null) { ViewController.NavigationController.InteractivePopGestureRecognizer.RemoveTarget(this, new ObjCRuntime.Selector(nameof(HandleBackSwipe))); ContentPageElement.SendBackButtonPressed(); } } }
When swiping back from the page which is my second page in the navigation stack, I get to my root page as expected. But when I carry on swiping back on the root page (it makes no sense to swipe back at the root page, i know, however a user could do it for any reason), the app freezes, meaning i am not able to click any button on the root page.
Has anyone experienced the same issue with a renderer like mine? Thanks in advance!