.Net MAUI iOS 向后滑动导航不适用于常规页面导航流程

问题描述 投票:0回答:1

我目前在应用程序中使用标准导航方法而不是 Shell 导航。我打算加入 iOS 向后滑动导航功能,希望它能够默认运行。但是,它并没有按预期工作。我遇到了一些讨论这个问题的帖子,例如:

https://learn.microsoft.com/en-us/answers/questions/1143556/how-to-disable-the-swipe-back-in-ios-using-net-mau?sort=votes

我尝试在下一页上使用此代码来启用滑动返回导航,但不幸的是,它没有按预期运行:

所以我当前的导航流程是这样的:

MainPage = new NavigationPage(new Page1());

来自第1页:

async void Button_Clicked(System.Object sender, System.EventArgs e)
{
    await Navigation.PushAsync(new Page2());
}

在Page2的OnAppearing()上:

protected override void OnAppearing()  
{  
    base.OnAppearing();  
#if IOS  
    UINavigationController vc = (UINavigationController)Platform.GetCurrentUIViewController();//using UIKit, find the UINavigationController  
    vc.InteractivePopGestureRecognizer.Enabled = true;  
#endif  
}
ios xamarin xamarin.forms maui .net-8.0
1个回答
0
投票

正如你所说,向后滑动是 iOS 的默认行为。你不必在OnAppearing中设置以下内容,

#if IOS  
    UINavigationController vc = (UINavigationController)Platform.GetCurrentUIViewController();//using UIKit, find the UINavigationController  
    vc.InteractivePopGestureRecognizer.Enabled = true;  
#endif  

但我认为这可能与XCode或模拟器中模拟器的一些设置有关。请确保选择

Show Device Bezels
选项。

您还可以将其部署到物理设备 iPhone 上,看看它是否有效。

© www.soinside.com 2019 - 2024. All rights reserved.