UISearchController 中的 searchBar 在 iPad 上的拆分视图上未正确显示 [英] searchBar from UISearchController not showing correctly on split view on iPad

查看:20
本文介绍了UISearchController 中的 searchBar 在 iPad 上的拆分视图上未正确显示的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

今天我将代码从 UISearchDisplayController(在 iOS 8 中已弃用)迁移到 UISearchController,现在搜索栏并不总是正确显示.

Today I migrated my code from UISearchDisplayController (deprecated in iOS 8) to UISearchController and the search bar now is not always showing correctly.

我使用的是始终显示主列的 UISplitViewController(在 iPad/iPhone6+ 上也是如此).

I'm using a UISplitViewController that is ALWAYS showing the master column (so also on an iPad/iPhone6+ in portrait).

我更喜欢这种视觉效果,而不是用户必须从左向右滑动才能看到该列.

I prefer this visually over the user having to swipe from left to right to see that column.

如果打开应用程序并点击主列中的项目,则会加载详细信息列并适当调整搜索栏的大小.

If open the application an tap on an item in the master column, the detail column loads and the searchBar is resized appropriately.

但是,如果我打开应用程序并在搜索栏中输入一些内容,然后点击其中一个结果,详细信息也会正确加载,但不会调整搜索栏的大小.

However if I open te application en enter something in the searchBar, then tap on one of the results the detail also loads correctly but the searchBar is NOT resized.

附录:我刚刚发现 iPhone 上的东西也不完美:它在 detailView 上显示 searchBar :

Addendum: I just found out that on iPhone things aren't perfect either: it shows the searchBar on the detailView :

(无论是否显示导航控制器)

(And this is both with or without the navigation controller showing)

grrr 我很想回到旧的 UISearchDisplayController

grrr I'm tempted to go back to the good old UISearchDisplayController

推荐答案

经过多次谷歌搜索发现,在我的 TableViewController 的 ViewDidLoad 中添加这行代码解决了问题:

After much googling found out that adding this line of code in my ViewDidLoad of my TableViewController fixed the problem :

self.definesPresentationContext = true

这篇关于UISearchController 中的 searchBar 在 iPad 上的拆分视图上未正确显示的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆