UISearchController: searchBar and scopeBar overlap on first touch event

前端 未结 3 2126
清酒与你
清酒与你 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:50

    This appears to be a known defect. There are several radr entries such as http://www.openradar.me/20702394 that refer to similar issues and a workaround by using sizeToFit()

    The workaround they suggest works, but only when it was applied within viewDidLayoutSubviews. i.e. after all of the views were laid out.

    override func viewDidLayoutSubviews() {
        self.searchController.searchBar.sizeToFit()
    }
    

提交回复
热议问题