移动SearchBar表视图 [英] Moving SearchBar table view

查看:72
本文介绍了移动SearchBar表视图的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个搜索栏和一个搜索显示控制器,并实现了相关方法。在我的 xib 中,此搜索栏上方有一个文本字段。我希望表格视图显示在我的搜索栏下方,而不要覆盖搜索栏或上方的文本字段。

I have a search bar and a search display controller with the associated methods implemented. In my xib, I have a text field above this search bar. I want the table view that appears to appear below my search bar and not to cover the search bar or the text field above it.

我已经尝试过:

self.searchDisplayController.searchResultsTableView.frame = CGRectMake(0, 247, 320, 400);

但这似乎没有任何效果。如何设置 UITableView 位置?

But this doesn't seem to have any effect. How do I set the UITableView position?

确定-这样做-

- (void)searchDisplayController:(UISearchDisplayController *)controller didShowSearchResultsTableView:(UITableView *)tableView {
tableView.frame = CGRectMake(0, 200, 320, 400);

}

该表显示在下面搜索栏,但由于某种原因,我无法单击上方的文本字段。我认为发生这种情况是因为表视图仍然覆盖了该字段,并且我认为这是因为当我单击搜索栏并开始键入时,会出现一个灰色区域,该区域覆盖了所有内容。

The table is appearing below the search bar, but for some reason I cannot click the text field above. I think that is happening because said field is still being covered by the table view and the reason I think this is because when I click on the search bar and begin typing a grey area appears that covers everything.

推荐答案

一个老问题,但我还是想回答,希望对其他人有所帮助-我遇到了同样的问题并在每次更新搜索字符串/结果时都调用scrollRect起作用-您需要引用视图控制器(在本例中为self.displayController)来显示搜索结果。

An old question but I thought I'd answer anyway in the hope it might help someone else -I had the same issue and calling scrollRect whenever the search string/results were updated worked - you need a reference to the view controller (self.displayController in this case) which displays the search results.

    [self.displayController.tableView scrollRectToVisible:CGRectMake(0, 0, 1, 1) 
                                                 animated:NO];

这篇关于移动SearchBar表视图的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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