当UISearchBar处于活动状态时,UITableView内容与状态栏重叠 [英] UITableView content overlaps Status Bar when UISearchBar is active

查看:385
本文介绍了当UISearchBar处于活动状态时,UITableView内容与状态栏重叠的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个带UISearchBar和UISearchDisplayController的UITableViewController。它存在于UIVavigationController中的UIViewController中的Container视图中。我制作了这张图片来帮助描述结构:





这就是它的真实情况:







一旦我开始输入一些搜索文本,结果显示出来。如果我向上滚动这些结果,它们会在搜索栏下方传递,但它们与状态栏重叠,这非常没有吸引力。





如果没有涉及容器视图,那么这一切都按预期工作,表内容在状态栏下面传递,但是涉及到ContainerView时,表格文本和状态栏会发生碰撞。 / p>

如何让状态栏下的文字正常运行?

解决方案

我已搜索了几个小时,我的最终结果是将此行放入viewDidLoad:
self.extendedLayoutIncludesOpaqueBars = YES;



问题解决了:)


I have a UITableViewController with a UISearchBar and UISearchDisplayController. That exists inside a Container View in a UIViewController which is in a UINavigationController. I made this image to help describe the structure:

This is what it really looks like:

When I tap the Search Bar, I have to hide the Nav Bar. Normally, this would happen on its own, but since my UITableViewController is inside a Container View, I have to handle that change myself. This is what it looks like then, note that the Status Bar is white because the Nav Bar is white, even though it is Hidden at the moment.

Once I start typing in some search text, the results show up. If I scroll those results upward, they pass underneath the Search Bar, but they overlap the Status bar which is very unattractive.

If the Container View isn't involved, then this all works as intended and the table content passes underneath the Status Bar, but with the ContainerView involved, the table text and status bar collide.

How do I get the text to travel under the Status Bar like normal?

解决方案

I have search this for hours and my final result was to put this line in viewDidLoad: self.extendedLayoutIncludesOpaqueBars = YES;

Problem solved :)

这篇关于当UISearchBar处于活动状态时,UITableView内容与状态栏重叠的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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