简体   繁体   English

嵌入导航栏中的 UISearchController 的表格视图和搜索栏的奇怪 animation

[英]Weired animation of tableview and searchbar of UISearchController embed in navigationbar

I've embed UISearchController into the navigationbar and my view controller has the table view.我已将 UISearchController 嵌入到导航栏中,并且我的视图 controller 具有表格视图。 When I click on searchbar and keyboard appears tableview and searchbar does not animate smoothly.当我点击搜索栏和键盘出现表格视图和搜索栏动画不流畅。 It seems like searchbar is overlaping navigationbar.似乎搜索栏与导航栏重叠。

Here is the code,这是代码,

Declare searchcontroller as a variable like,将 searchcontroller 声明为变量,例如,

var resultSearchController = UISearchController()

and defination in viewDidLoad is like, viewDidLoad 中的定义就像,

self.resultSearchController = ({
        let controller = UISearchController(searchResultsController: nil)
        controller.searchResultsUpdater = self
        controller.obscuresBackgroundDuringPresentation = false;
        self.navigationItem.searchController = controller
        return controller
    })()

Animation issue is like below gif(watch till end to see slow animation) Animation 问题如下 gif 所示(观看到最后看到慢动画)

在此处输入图像描述

I want same duration for animation for tableview, navigation bar, and searchbar.对于表格视图、导航栏和搜索栏,我希望 animation 的持续时间相同。

Any help will be appreciated.任何帮助将不胜感激。

Don't set UITableView top anchor to be pinned to safeArea but to superview .不要将UITableView顶部锚点设置为固定到safeArea但到superview

Important extra note to the accepted answer: If you use a UIViewController with subviews, including a UITableView , the UITableView has to be the first subview (ie: at index 0).对已接受答案的重要额外说明:如果您将UIViewController与子视图一起使用,包括UITableView ,则UITableView必须是第一个子视图(即:在 index0 处)。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM