Skip to content

Instantly share code, notes, and snippets.

@simonemarra
Created January 10, 2020 10:00
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save simonemarra/00b12c30dd948c08f5eb920dd7a33295 to your computer and use it in GitHub Desktop.
Save simonemarra/00b12c30dd948c08f5eb920dd7a33295 to your computer and use it in GitHub Desktop.
Xamarin Forms (iOS): disable swipe back on provided page via custom renderer
using Xamarin.Forms;
[assembly: ExportRenderer(typeof(Appname.Views.DeviceInfoPage), typeof(Appname.iOS.Renderers.NoSwipeBackPageRenderer))]
namespace Appname.iOS.Renderers
{
// Custom Rendered to disable the swipe back of provided page type (in this case DeviceInfoPage...)
// source: https://forums.xamarin.com/discussion/26966/how-to-disable-swipe-gesture-on-pushed-page
public class NoSwipeBackPageRenderer : PageRenderer
{
public override void ViewDidAppear(bool animated)
{
base.ViewDidAppear(animated);
var navctrl = this.ViewController.NavigationController;
navctrl.InteractivePopGestureRecognizer.Enabled = false;
}
}
}
@KMRH47
Copy link

KMRH47 commented Dec 7, 2021

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment