UISearchController - Search text clear icon does not hide completely

和自甴很熟 提交于 2019-12-08 10:08:45

问题


I am setting up searchController as below in viewDidLoad() in my view controllers. One VC has table view embedded and another is UITableViewController.

I am using another VC to allow user to select a value and use that to filter tables items using unwind segue.

self.searchController.obscuresBackgroundDuringPresentation = false
    self.searchController.hidesNavigationBarDuringPresentation = true

if #available(iOS 11.0, *)  {


    self.searchController.searchBar.delegate = self
    self.navigationItem.searchController = self.searchController
    self.navigationController?.navigationBar.prefersLargeTitles = true            
    self.searchController.searchBar.scopeButtonTitles = ["All", "<= 2", "<= 5", "<= 10"]

    self.navigationItem.hidesSearchBarWhenScrolling = true

}

i do the below in unwind method.

DispatchQueue.main.async {

                self.searchController.searchBar.text = searchText

                let scope = self.searchController.searchBar.scopeButtonTitles![self.searchController.searchBar.selectedScopeButtonIndex]

                self.filterContentForSearchText(searchText, scope: scope)

            }

When table with data is loaded, search bar is hidden completely under navigation bar but when i assign value to the searchtext field that doesnt yield any items from data source, the search field clear icon shows as below.

I am using DZNEmptyDataSet framework to handle empty views. Earlier i had configured search bar from IB and at that below issue didnt come. Was using DZNEmptyDataSet at that time also.

What could be the issue?

Xcode 9.3 Testing in 11.3 simulator and 8 Plus.

Thanks Ashish

来源:https://stackoverflow.com/questions/50491116/uisearchcontroller-search-text-clear-icon-does-not-hide-completely

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!