searchBar from UISearchController not showing correctly on split view on iPad

北慕城南 提交于 2019-12-24 04:25:06

问题


Today I migrated my code from UISearchDisplayController (deprecated in iOS 8) to UISearchController and the search bar now is not always showing correctly.

I'm using a UISplitViewController that is ALWAYS showing the master column (so also on an iPad/iPhone6+ in portrait).

I prefer this visually over the user having to swipe from left to right to see that column.

If open the application an tap on an item in the master column, the detail column loads and the searchBar is resized appropriately.

However if I open te application en enter something in the searchBar, then tap on one of the results the detail also loads correctly but the searchBar is NOT resized.

Addendum: I just found out that on iPhone things aren't perfect either: it shows the searchBar on the detailView :

(And this is both with or without the navigation controller showing)

grrr I'm tempted to go back to the good old UISearchDisplayController


回答1:


After much googling found out that adding this line of code in my ViewDidLoad of my TableViewController fixed the problem :

self.definesPresentationContext = true


来源:https://stackoverflow.com/questions/32171704/searchbar-from-uisearchcontroller-not-showing-correctly-on-split-view-on-ipad

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