iOS 13 strange search controller gap

前端 未结 12 2035
无人共我
无人共我 2021-02-01 14:55

When running the App on iOS 13 beta 6, using Xcode 11 beta 5 I\'m encountering the strange gap when presenting search results view controller:

Here\'s a bit o

12条回答
  •  被撕碎了的回忆
    2021-02-01 15:28

    For me the problem was that UISearchController didn't update it's frame when search bar moved upwards. I fixed it by setting frame of UISearchController to the frame of it's presenting view controller.

    extension UISearchController {
        open override func viewWillAppear(_ animated: Bool) {
            super.viewWillAppear(animated)
            if let presentingVC = self.presentingViewController {
                DispatchQueue.main.asyncAfter(deadline: .now() + 0.1) {
                    self.view.frame = presentingVC.view.frame
                }
            }
        }
    }
    

    In viewWillAppear animation of search bar did not start so you have to wait for a split second. When animation starts, frame of presenting VC is set to the correct value and then you can update frame of your UISearchController. The solution is a hack but it works fine for me.

提交回复
热议问题