UISearchbar 结果在表格视图中显示不一致

发布于 2024-10-08 04:35:09 字数 547 浏览 0 评论 0原文

我正在根据用户在搜索栏中输入的内容对外部 API (XML) 使用实时搜索。

我正在使用不区分大小写的搜索。事情运行得很好,直到我移动了代码或者更确切地说添加了一个线程。突然间,我得到的结果有点一致。它们并没有错,但有时数量较少。

例如,如果用户输入“a”,它将显示大约 7 个结果,例如 AAR、Aaron、Staar、Mtaar ... 那么如果输入“aa”,就会显示1个结果(AAR),那么如果输入“aar”,就会显示3个结果AAR、Star、Mtaar 再次,如果按下退格键并且搜索栏中的当前术语是 aa,它现在将显示 3 个结果...

另一个例子,如果我输入“goog”,它在表格单元格结果中不显示任何内容(即使我看到它已经解析了 Google),而如果我添加一个“l”,即如果该术语现在是“googl”,它现在会在下面的单元格中显示 Google。 解析完成后我将立即更新表视图。

所以基本上在我添加线程之后,搜索结果有点不一致。我不知道为什么。

请注意,在所有情况下,显示的结果都是正确的,但只是错误。其中各不相同。

有人可以帮我解决这个问题吗?

多谢。

I am using a real-time search against an external API (XML) based on what the user is entering in the search bar..

I am using a case-insensitive search. The thing was working fine, until I moved the code or rather added a thread. Suddenly the results that I get are a bit consistent. They are not incorrect, but they are sometimes lesser in number.

e.g. if a user enters "a", it will show around 7 results, say AAR, Aaron, Staar,Mtaar ...
Then if enters "aa" , it will show 1 result (AAR), then if he enters "aar", it will show 3 results AAR, Star, Mtaar
Again if backspace is pressed and if the current term in the search bar is aa, it will now show 3 results...

Another example, if I type "goog", it displays nothing in the table cell results (even though i see that it has parsed Google), while if i add an "l", i.e. if the term is now "googl", it now shows Google in the cell below.
I am updating my table view immediately after the parsing is complete.

So basically after I added thread, the search results have got a bit inconsistent. I am not sure why.

Note that in all cases the results shown are all correct, but just the no. of them is varying.

Could someone please help me with the issue.

Thanks a lot.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

锦欢 2024-10-15 04:35:09

您能否提供一些示例代码如何访问过滤后的表内容数组?您可以 NSLog() 从 API 获得的结果并与 tableView 中显示的结果进行比较。

can you provide some sample code how you access your filtered table content array? You can NSLog() the result you get from the API and compare with the ones are displayed in your tableView.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文