iPhone SDK:设置 UISearchDisplayController 的表格视图的大小
我的应用程序的表格视图不占据整个屏幕高度,因为我允许底部有 50 像素的横幅。
当我开始在搜索栏中输入内容时,搜索结果表格视图会变大;它填充了搜索栏和选项卡栏之间的所有可用屏幕空间。这意味着最后的搜索结果被横幅遮盖了。
如何指定 UISearchDisplayController 使用的表视图的大小?我看不到任何边界或框架属性。
编辑添加屏幕:
这就是在 IB 中设置表视图的方式。它结束于合成标签栏 50px 处。
(来源:lightwood.net)
这是内容显示正常。我已经滚动到这里的最底部。
(来源:lightwood.net)
就是这样搜索时显示。我再次滚动到最底部。如果我禁用横幅广告,我可以看到搜索显示表直接向下延伸到标签栏。
(来源:lightwood.net)
My app's table view does not occupy the full screen height, as I've allowed 50px at the bottom for a banner.
When I begin typing in the search bar, the search results table view is larger; it fills all available screen space between the search bar and the tab bar. This means that the very last search result is obscured by the banner.
How do I specify the size of the table view used by UISearchDisplayController? There's no bounds or frame property that I can see.
EDIT TO ADD SCREENSHOTS:
This is how the table view is set up in IB. It ends 50px short of the synthesized tab bar.
(source: lightwood.net)
This is how content displays normally. I've scrolled to the very bottom here.
(source: lightwood.net)
This is how it displays when searching. Again, I've scrolled to the very bottom. If I disable the banner ad, I can see that the search display table spreads right down to the tab bar.
(source: lightwood.net)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
解决这个问题的关键是找出何时更改表格视图的几何形状。 调用
创建 UISearchDisplayController 之后 是徒劳的。答案是这个委托方法:
注意,我也尝试过
-searchDisplayController:didLoadSearchResultsTableView
但它在那里没有什么好处。您必须等到它显示才能调整其大小。另请注意,如果您简单地指定
tableView.frame = otherTableView.frame
,则搜索结果表格会与其相应的搜索栏重叠,因此无法清除或取消搜索!我的最终代码如下所示:
The key to solving this one was finding out when to change the geometry of the table view. Calling:
after creating the UISearchDisplayController was futile. The answer was this delegate method:
Note, I had also tried
-searchDisplayController:didLoadSearchResultsTableView
but it did no good in there. You have to wait until it's displayed to resize it.Also note that if you simply assign
tableView.frame = otherTableView.frame
, the search results table overlaps its corresponding search bar, so it is impossible to clear or cancel the search!My final code looked like this:
我更新了代码以允许更深的视图层次结构,但半透明封面视图的初始框架仍然占据搜索栏下方的整个窗口。
I updated the code to allow for deeper view hierarchies, but the initial frame of the semi-transparent cover view still takes up the entire window below the search bar.
我不确定我完全理解你所描述的内容,最好有截图。
听起来发生的事情是 UITableView 是屏幕的大小,并且横幅与屏幕底部的 50 像素重叠。所有 UIView 子级都有从其公共 UIView 父级继承的框架、边界和中心属性。
您可以根据需要操纵这些属性,听起来您只需将边界调整为比屏幕小 50 像素,并进行一些数学计算来计算新的中心。
I'm not sure I completely understand what you're describing, it would be nice to have a screenshot.
It sounds like what's happening is the UITableView is the size of the screen and the banner is overlapping the bottom 50 pixels of it. All UIView children have a frame, bounds, and center properties they inherit from their common UIView parent.
You can manipulate these properties as you like, it sounds like you simply need to adjust the bounds to be 50 pixels smaller than the screen, and do some math to calculate your new center.