UISearchController 搜索栏隐藏 tableview 中的第一个单元格 [英] UISearchController searchbar hides the first cell in tableview

查看:26
本文介绍了UISearchController 搜索栏隐藏 tableview 中的第一个单元格的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个带有搜索栏的表格视图.搜索栏由 UISearchController 提供.当我将搜索栏添加到表格的标题视图时,表格的第一行被搜索栏覆盖.

I have a tableview with a search bar. The search bar is provided by a UISearchController. When I add the search bar to the header view of the table, the first row of the table gets covered by the search bar.

如何防止搜索栏隐藏第一行?

How do I prevent the search bar from hiding the first row?

我在 viewDidLoad 中有这个片段:

I have this snippet in viewDidLoad:

self.searchController = UISearchController(searchResultsController: nil)
self.searchController.searchResultsUpdater = self
self.searchController.searchBar.delegate = self     
self.tableView.tableHeaderView = self.searchController.searchBar
self.searchController.dimsBackgroundDuringPresentation = false
self.searchController.searchBar.sizeToFit()

推荐答案

如果您没有范围按钮标题,似乎必须明确设置范围按钮标题数组.

It seems that you have to explicitly set the scope button titles array if you don't have scope button titles.

self.searchController.searchBar.scopeButtonTitles = [NSArray array];

这篇关于UISearchController 搜索栏隐藏 tableview 中的第一个单元格的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆