简体   繁体   English

取消UISearchController会破坏分组的UITableViewController视觉效果

[英]Dismissing UISearchController breaks grouped UITableViewController visual

I have a UITableViewController that shows countries group by the alphabet. 我有一个UITableViewController ,可以按字母顺序显示国家/地区。 I added a UISearchController in code: 我在代码中添加了UISearchController

let searchController = UISearchController(searchResultsController: nil)

searchController.searchBar.placeholder = ""
searchController.searchResultsUpdater = self
searchController.dimsBackgroundDuringPresentation = false
definesPresentationContext = true
tableView.tableHeaderView = searchController.searchBar

The problem is that when I dismiss the search bar, the UI visual kind of breaks, showing a strange space above the search bar: 问题是,当我关闭搜索栏时,UI视觉会中断,在搜索栏上方显示一个奇怪的空间:

在此处输入图片说明

Any ideas why this happens and how to solve it? 有什么想法为什么会发生以及如何解决?

Try adding: 尝试添加:

searchController.hidesNavigationBarDuringPresentation = false
searchController.searchBar.sizeToFit()

self.definesPresentationContext = true

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 UISearchController在解雇它时有奇怪的行为 - UISearchController weird behavior on dismissing it UISearchController不在UITableViewController中搜索 - UISearchController not searching in UITableViewController 解除UITableViewController时出错 - Error while dismissing UITableViewController UISearchController在以模态方式解除时发出问题 - UISearchController issues when dismissing modally 取消UITableViewController会更改ADBannerView位置 - Dismissing UITableViewController changes ADBannerView location 在关闭UISearchController时,UINavigationBar涵盖UITableView - UINavigationBar covers UITableView when dismissing UISearchController 带有大标题的 UISearchController,UI 在关闭时行为不端 - UISearchController with Large titles, UI misbehave on dismissing UITableViewController(结果控制器)中带有UISearchController的自定义单元格 - Custom cell with UISearchController in UITableViewController (result controller) 需要像UISearchDisplayController一样使用没有UITableViewController的UISearchController - Need to use UISearchController without UITableViewController like a UISearchDisplayController 使用UISearchController和Objective-C搜索UITableView而不是UITableViewController - Searching a UITableView not a UITableViewController with UISearchController and Objective-C
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM