[英]Issue with NavigationBarTitle when scrolling List with TextFields inside of it
I have a simple checklist app that uses a SwiftUI List
view to display sections with list items inside of it.我有一个简单的清单应用程序,它使用 SwiftUI List
视图来显示其中包含列表项的部分。
Because I want the list items to be editable, each list row has a TextField
inside of it with the item name in it.因为我希望列表项是可编辑的,所以每个列表行内部都有一个TextField
,其中包含项目名称。 However, if I focus into a text field and scroll the list before hitting the Return Key
, the large navigationBarTitle
has a bug where it remains frozen in place.但是,如果我在点击Return Key
之前专注于文本字段并滚动列表,则大型navigationBarTitle
存在一个错误,即它仍然冻结在原地。 For it to work properly, I have to back out of the page and come back.为了让它正常工作,我必须退出页面并返回。
I'm not seeing any errors, so I'm not sure why this occurring.我没有看到任何错误,所以我不确定为什么会发生这种情况。 I have a suspicion using a wrapped UITextField might solve this, but I'm not sure.我怀疑使用包装的 UITextField 可能会解决这个问题,但我不确定。
I was able to fix my own issue while trying to create a reproducible example.在尝试创建可重现的示例时,我能够解决自己的问题。
The bug was the result of a background color I was applying to the parent Group
that contained the List
.该错误是我将背景颜色应用于包含List
的父Group
的结果。 Removing the background color fixed my issue!删除背景颜色解决了我的问题!
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.