gpt4 book ai didi

ios - 除非我点击搜索栏,否则 SearchController 不会显示未过滤的结果

转载 作者:行者123 更新时间:2023-11-30 11:42:07 25 4
gpt4 key购买 nike

我使用 searchController 在搜索所有用户的列表时获得良好的用户体验。但是,我希望用户在进入 searchController 时看到未过滤的用户列表。到目前为止,正如标题中所写,只有在我点击搜索栏后才会显示未过滤的结果。在此之前, TableView 是空的。如果我然后按下内置取消按钮,则未过滤的数据将保留。搜索功能运行得很好,但这个错误使其在用户体验方面毫无用处。

我读到 searchController 可能会在开始时覆盖 tableview,但首先我不知道这是否属实,其次,我不知道如何避免它。

有人知道如何解决这个问题吗?

最佳答案

您可以通过设置其 isActive 属性来强制 UISearchController 显示自身。 https://developer.apple.com/documentation/uikit/uisearchcontroller/1618659-isactive

When the user taps in the search field of a managed search bar, the search controller automatically displays the search results controller. Usually, you get the value of this property to determine whether the search results are displayed. However, you can set this property to true to force the search interface to appear, even if the user has not tapped in the search field.

The default value of this property is false.

关于ios - 除非我点击搜索栏,否则 SearchController 不会显示未过滤的结果,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49209893/

25 4 0