将 UISearchController 与 UINavigationController 内的 UITabBarController 一起使用时,搜索栏会被切断 [英] Search bar gets cut off when using UISearchController with a UITabBarController inside a UINavigationController
问题描述
我有一个在 UINavigationController
中有一个 UITabBarController
的应用程序.(UITabBarController
不是故事板的初始视图控制器".)
在最初的 UIViewController
中,我有一个 UISearchController
允许从远程源搜索内容.
在我添加 UITabBarController
之前,这一切正常.现在,搜索栏在默认状态下显示正常,但是一旦您开始在其中输入内容,它就会被推到视图的顶部边缘.
我意识到这可能与 automaticallyAdjustsScrollViewInsets
、extendedLayoutIncludesOpaqueBars
和/或 edgesForExtendedLayout
有很大关系,但在我所有的调整中,我一直无法找到使 UISearchController
不将自身推到视图顶部的神奇组合.
关于如何让它发挥作用的任何想法?
从
I have an application that has a UITabBarController
in a UINavigationController
. (The UITabBarController
is not the "Initial View Controller" for the story board.)
In the initial UIViewController
, I have a UISearchController
which allows for content to be searched from a remote source.
This worked fine until I added the UITabBarController
. Now, the search bar displays fine in the default state, but once you start typing inside of it, it gets pushed up past the top edge of the view.
I realize this probably has a lot to do with automaticallyAdjustsScrollViewInsets
, extendedLayoutIncludesOpaqueBars
, and/or edgesForExtendedLayout
, but in all my tweaking, I've been unable to find the magic combo to get the UISearchController
to not push itself up past the top of the view.
Any ideas on how to make it work?
See these screengrabs from this example project:
Initial view:
Search text box becomes first responder:
After typing a word and hitting enter:
Although definesPresentationContext
worked for me previously, since iOS 10 at some point I had to disable Adjust Scroll View Insets on my search results view controller. More on my answer at UISearchBar gets cut off when using a UINavigationController inside a UITabBarController
这篇关于将 UISearchController 与 UINavigationController 内的 UITabBarController 一起使用时,搜索栏会被切断的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!