简体   繁体   English

在关闭UISearchController时,UINavigationBar涵盖UITableView

[英]UINavigationBar covers UITableView when dismissing UISearchController

I have a UINavigationBar with a search button. 我有一个带有搜索按钮的UINavigationBar。 The search button triggers a UISearchController: 搜索按钮触发一个UISearchController:

self.navigationItem.titleView = self.searchController.searchBar
self.searchController.searchBar.becomeFirstResponder()

When a user selects a search result, a new ViewController is pushed. 当用户选择搜索结果时,将推送一个新的ViewController。 If the user then taps back they are presented with the old ViewController with the still active search results. 如果用户随后点按,则会向他们显示具有仍处于活动状态的搜索结果的旧ViewController。

If they then tap Cancel to dismiss the UISearchController, the UINavigationBar now covers the content in the view. 如果他们然后点击取消以关闭UISearchController,则UINavigationBar现在将覆盖视图中的内容。 I think it may be my setting of self.definesPresentationContext to true in viewDidLoad and false when the next viewController is presented 我认为这可能是我对self.definesPresentationContext设置,在viewDidLoadtrue ,在下一个viewController出现时为false

从左到右的过程

If you think that you know the cause of the issue, have you tried commenting out those lines? 如果您认为知道问题的原因,是否尝试注释掉这些内容? Does it still do it then? 那它还在吗?

It sounds to me more like something to do with the UIViewController's automaticallyAdjustsScrollViewInsets property. 在我看来,这更像是与UIViewController的automaticallyAdjustsScrollViewInsets属性有关。

Try setting that to false on your UIViewController. 尝试在UIViewController上将其设置为false

EDIT: 编辑:

Have you tried changing the UIViewController's edgesForExtendedLayout property? 您是否尝试过更改UIViewController的edgesForExtendedLayout属性?

self.edgesForExtendedLayout = UIRectEdgeNone;

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

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM