在 swift 3 中优化搜索结果

Refining search results in swift 3

我有一个具有 Uicollection 视图的应用程序,每个单元格都包含大量详细信息,例如用户名、位置、可用日期、价格。所以我希望用户可以选择根据他们的需要过滤结果,例如所选日期的搜索栏或文本字段,另一个用于位置,另一个用于价格。这意味着我必须有多个搜索栏或文本字段我的问题是我知道如何制作单个搜索栏但我不知道如何制作多个。任何帮助都会非常有用。

你将 UISearchBars 输出到你的 UIViewController,然后在委托函数中

func searchBar(searchBar: UISearchBar, textDidChange searchText: String) {
      if searchBar == self.searchBar1 {
          //first search bar used
      } else if searchBar == self.searchBar2 {
      ...
}