IsGestureEnabled is not working in xamarin forms for iOS 16

113 Views Asked by At

I'm changing the orientation(Landscape/Portrait) forcefully for one screen. For that, I used IsGestureEnabled property. That property is not working on iOS 16 or above versions.

CODE:

protected override void OnDisappearing()
{
    SetGestureEnabled(true);
    base.OnDisappearing();
}

protected override void OnAppearing()
{
    SetGestureEnabled(false);
    base.OnAppearing();
}

private void SetGestureEnabled(bool isSet)
{
    if (Application.Current.MainPage is MasterDetailPage masterDetailPage)
    {
        masterDetailPage.IsGestureEnabled = isSet;
    }
}

Please help me to resolve this issue.

1

There are 1 best solutions below

0
Liqun Shen-MSFT On

MasterDetailPage is obsolete. Try using FlyoutPage instead.

FlyoutPage also has IsGestureEnabled property which could disable or enable the swipe gesture. The default value is true. you could use almost the same code in your question

if (Application.Current.MainPage is FlyoutPage flyoutPage)
{
    flyoutPage.IsGestureEnabled = true;
}

For more info, you could refer to Xamarin.Forms FlyoutPage