簡體   English   中英

滾動包含 TextFields 的列表時出現 NavigationBarTitle 問題

[英]Issue with NavigationBarTitle when scrolling List with TextFields inside of it

我有一個簡單的清單應用程序,它使用 SwiftUI List視圖來顯示其中包含列表項的部分。

因為我希望列表項是可編輯的,所以每個列表行內部都有一個TextField ,其中包含項目名稱。 但是,如果我在點擊Return Key之前專注於文本字段並滾動列表,則大型navigationBarTitle存在一個錯誤,即它仍然凍結在原地。 為了讓它正常工作,我必須退出頁面並返回。

我沒有看到任何錯誤,所以我不確定為什么會發生這種情況。 我懷疑使用包裝的 UITextField 可能會解決這個問題,但我不確定。

SwiftUI List with TextFields 滾動錯誤導航欄大標題粘性

在嘗試創建可重現的示例時,我能夠解決自己的問題。

該錯誤是我將背景顏色應用於包含List的父Group的結果。 刪除背景顏色解決了我的問題!

struct ChecklistView: View {
    var body: some View {
        Group {
            if empty {
                EmptyView()
            } else {
                ListView()
            }
        }
        .background(Color(.tertiarySystemBackground).edgesIgnoringSafeArea(.all)) // removing this line fixed my issue
        .navigationBarTitle("My title")
    }
}

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM