iOS 13 strange search controller gap

前端 未结 12 1685
无人共我
无人共我 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:26

    We had the same issue and the solution was to set Under Opaque Bars (since we use opaque bars)

    We already had Top and Bottom checked, adding the third moved the search results controller to the correct location.

    0 讨论(0)
  • 2021-02-01 15:26

    Finally get through the tough. Just to make the first controller contains the UISearchController to have a translucent navigationBar. Work for me perfectly!

        override func viewWillAppear(_ animated: Bool) {
            super.viewWillAppear(animated)
    
            self.navigationController?.navigationBar.isTranslucent = true
        }
    
        override func viewWillDisappear(_ animated: Bool) {
            super.viewWillAppear(animated)
    
            self.navigationController?.navigationBar.isTranslucent = false
        }
    
    0 讨论(0)
  • 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.

    0 讨论(0)
  • 2021-02-01 15:29

    extendedLayoutIncludesOpaqueBars = true did help to some extent.

    Along with this, I had to update

    navigationController?.navigationBar.prefersLargeTitles = false

    when we start searching and set it back to true when search bar is dismissed.

    0 讨论(0)
  • 2021-02-01 15:34

    Setting

    extendedLayoutIncludesOpaqueBars = true
    

    in the UIViewController used to show the search results, fixed the issue for me.

    0 讨论(0)
  • 2021-02-01 15:34

    The easiest solution is to set this on your searchResultsController:

    searchResultsController.edgesForExtendedLayout = UIRectEdgeNone;
    
    0 讨论(0)
提交回复
热议问题