简体   繁体   English

如何从 swiftui 导航堆栈中删除后退按钮,但允许用户在从屏幕左侧捏住屏幕时向后移动

[英]How to remove back button from swiftui navigation stack but allow the user to move back when the screen is pinched from the left side of the screen

I my swiftui navigation stack i want to remove the back button from the view but i want to allow the user to move to the previous screen when it is pinched from the left hand side我的 swiftui 导航堆栈我想从视图中删除后退按钮,但我想让用户在从左侧捏住时移动到上一个屏幕

@main
struct MyApp: App {
    
    @State private var path = [String]()
    
    var body: some Scene {
        WindowGroup {
            NavigationStack(path: $path){
                FirstView(path: $path)
            }.navigationDestination(for: String.self) { string in
                SecondView()
                
            }
        }
    }
}

Now in my SecondView i have added .navigationBarHidden(true) which removes the back button but also removes the ability to pinch back to the previous view现在,在我的 SecondView 中,我添加了.navigationBarHidden(true) ,它删除了后退按钮,但也删除了收缩回到上一个视图的能力

You can find the answer here which works by extending UINavigationController and adding a UIGestureRecognizerDelegate.您可以在此处找到答案,该答案可以通过扩展 UINavigationController 并添加 UIGestureRecognizerDelegate 来实现。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Swift 5 - 如何在没有后退按钮的情况下隐藏导航栏中的后退按钮或移动到另一个屏幕 - Swift 5 - How to hide back button in Navigation bar or move to another screen without back button React Native:从导航堆栈中删除后退按钮? - React Native: Remove a back button from navigation stack? 如何从导航栏中删除后退按钮 - How to remove back button from navigation bar 后退按钮从屏幕上消失 - Back button disappearing from screen 如何从导航链接列表的左侧删除填充? SwiftUI - How to remove padding from the left side of list of navigation links? SwiftUI 显示 Segue 未进入导航堆栈。 视图控制器上没有出现后退按钮,它是从底部而不是左侧向上滑动 - Show Segue not entering navigation stack. No back button appears on the View Controller, and it is sliding up from bottom not the left side 如何使用swiftui iOS 13从整个应用程序的导航栏中删除后退按钮 - How to remove back button from navigation bar in whole app using swiftui iOS 13 SwiftUI-有没有办法从另一个视图 go 返回主屏幕而不显示后退按钮? - SwiftUI-Is there a way to go back to the home screen from another view without the back button appearing? 如何在“初始屏幕”的导航栏中隐藏Web视图的“后退”按钮? - How to Hide Web View's Back Button from navigation bar in Initial Screen? 从 SwiftUI 中的导航栏中删除后退按钮文本 - Remove back button text from navigationbar in SwiftUI
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM