Swiftui 如何修复手动从子视图解除到父视图以及从拖动解除时导航栏标题重叠的问题?

Swiftui 如何修复手动从子视图解除到父视图以及从拖动解除时导航栏标题重叠的问题?,swiftui,Swiftui,在SwiftUI中从子视图解除到父视图时,导航栏标题重叠了几毫秒,这是由于调用函数或拖动以解除而引起的 以下是UI中的错误: 这是我不考虑的函数的代码 struct AddRecipeView: View { //dismiss to parent view method @Environment(\.presentationMode) var presentationMode //control to verify if user is editing an ex

在SwiftUI中从子视图解除到父视图时,导航栏标题重叠了几毫秒,这是由于调用函数或拖动以解除而引起的

以下是UI中的错误:

这是我不考虑的函数的代码

struct AddRecipeView: View {

    //dismiss to parent view method
    @Environment(\.presentationMode) var presentationMode

    //control to verify if user is editing an existing recipe
    @State var editingExistingRecipe = false

    //recipe details
    @EnvironmentObject var recipeDetails: RecipeDetails 

    var body: some View {

        VStack {
            List {
                //code
            }.navigationBarTitle("New Recipe")
        }
        .onAppear {
            //check if user is editing an existing recipe to update details
            if self.editingExistingRecipe == true {

                //update details
                self.updateDetails()

                self.editingExistingRecipe = false
            }
        }
        .edgesIgnoringSafeArea(.bottom)
    }

    func postRecipe(userid: String) {

        self.recipeCategory = self.recipeDetails.recipeCategorySelected
        self.recipeCategoryID = self.recipeDetails.recipeCategorySelectedID

        let Category = self.recipeCategory
        let CategoryID = self.recipeCategoryID

        let details = [
            Category,
            CategoryID
        ]


        for detail in details {
            //check if items are not empty
            print("detail: \(detail)")
            guard !detail.isEmpty else {
                print("empty detail: \(detail)")
                return self.showingAlert = true
            }
        }    

        let db = Firestore.firestore()
        let recipes = db.collection("users/0000/recipes")
        let recipe = recipes.document()

        if self.recipeID.isEmpty {

            recipes.addDocument(data: [
                "category"          : Category,
                "category id"       : CategoryID,
            ]) { err in
               if err != nil {
                    print((err?.localizedDescription)!)
                    return
                }
                print("Success")
            }

            self.recipeDetails.reset()

            DispatchQueue.main.async {
                //dismiss to parent view
                self.presentationMode.wrappedValue.dismiss()
            }
        } else {
            print("doc id = \(self.recipeID)")

            recipes.document(self.recipeID).updateData([
                "category"          : Category,
                "category id"       : CategoryID,
            ]) { err in
               if err != nil {
                    print((err?.localizedDescription)!)
                    return
                }
                print("Success")
            }

            DispatchQueue.main.async {
                //dismiss to parent view
                self.presentationMode.wrappedValue.dismiss()
            }
        }
    }
}


你们知道为什么会这样吗?我是swift新手,谢谢你的帮助。

你可以发布更多的身体代码,看看你是忽略了顶部还是隐藏了导航barHi@fakiho我更新了代码,非常感谢!