List 使用搜索栏过滤长列表的速度非常慢
我有一个多达100项的清单。使用搜索栏过滤列表时,每个字母都需要一些时间。 如何加快搜索速度? 一种可能的解决方案是只在单击键盘上的搜索按钮后进行过滤List 使用搜索栏过滤长列表的速度非常慢,list,filter,swiftui,searchbar,List,Filter,Swiftui,Searchbar,我有一个多达100项的清单。使用搜索栏过滤列表时,每个字母都需要一些时间。 如何加快搜索速度? 一种可能的解决方案是只在单击键盘上的搜索按钮后进行过滤 VStack { SearchBar(text: $searchTerm, placeholder: "Suche") } List {
VStack {
SearchBar(text: $searchTerm, placeholder: "Suche")
}
List {
ForEach(gesetzestextTEMPO.filter {
self.searchTerm.isEmpty ? true : $0.titel1.localizedCaseInsensitiveContains(searchTerm)
|| $0.titel1.localizedCaseInsensitiveContains(searchTerm)
|| $0.artikel.localizedCaseInsensitiveContains(searchTerm)
|| $0.marginale.localizedCaseInsensitiveContains(searchTerm)
|| $0.absatz0.localizedCaseInsensitiveContains(searchTerm)
|| $0.absatz0litaz.localizedCaseInsensitiveContains(searchTerm)
})
{ item in
Part13(gesetzestextTEMPO: item, searchTerm: self.$searchTerm)
}
}```
请尝试以下操作:
List {
// ...
}
.id(UUID())
按照这里的提议: