UISearchController: searchBar and scopeBar overlap on first touch event

前端 未结 3 2123
清酒与你
清酒与你 2021-02-10 09:22

I\'m trying to implement a simple search bar using Apple\'s latest UISearchController. However I can\'t seem to get it to work correctly if I use the search bar

3条回答
  •  终归单人心
    2021-02-10 09:39

    I just spent three days working on this same issue going through all of the posts I could find and just finally found the solution on the Apple Dev forum so thought I would post an update to help the next person that encounters this issue.

    The resolution is to make sure that the showsScopeBar property on the search bar belonging to a UISearchController is set to false, i.e. UISearchController.searchBar.showsScopeBar = false in Swift.

    The issue seems to be that Apple's design intent is for the showsScopeBar property to be used with standalone search bars not search bars controlled by a UISearchController. Unfortunately this is not called out in the class documentation. Bad design decision in my opinion but it is what it is.

    The discussion is in the following thread https://devforums.apple.com/thread/235803 (dead link as of 2018-01-26).

    Best of luck.

提交回复
热议问题