简体   繁体   中英

UINavigationBar covers UITableView when dismissing UISearchController

I have a UINavigationBar with a search button. The search button triggers a UISearchController:

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

When a user selects a search result, a new ViewController is pushed. If the user then taps back they are presented with the old ViewController with the still active search results.

If they then tap Cancel to dismiss the UISearchController, the UINavigationBar now covers the content in the view. I think it may be my setting of self.definesPresentationContext to true in viewDidLoad and false when the next viewController is presented

从左到右的过程

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.

Try setting that to false on your UIViewController.

EDIT:

Have you tried changing the UIViewController's edgesForExtendedLayout property?

self.edgesForExtendedLayout = UIRectEdgeNone;

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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