隐藏ios 7时,搜索栏变为白色

时间:2013-10-18 19:46:07

标签: iphone ios7 uisearchbar

我正在尝试隐藏搜索栏,直到用户向上滚动。它可以工作,但是当用户滚动时,搜索栏显示为白色。我正在使用此代码隐藏它:

self.tableView.contentOffset = CGPointMake(0.0, 44.0);

我也尝试过使用:

CGRect newBounds = self.tableView.bounds;
newBounds.origin.y = newBounds.origin.y + self.SearchBar.bounds.size.height;
self.tableView.bounds = newBounds;

这就是:

Before scrolling

After scrolling

滚动后它应该是这样的: Example

2 个答案:

答案 0 :(得分:5)

尝试使用搜索显示控制器替换TableView +搜索栏,然后将代码放在viewWillAppear中。

self.tableView.contentOffset = CGPointMake(0.0, 44.0);

enter image description here

答案 1 :(得分:0)

好的,感谢Pyraego.com,我能够解决我的问题。首先,我删除了搜索栏,然后将其替换为搜索显示控制器。然后,我使用了完美运行的方法self.tableView.contentOffset = CGPointMake(0.0, 44.0);(我在“viewWillAppear”中添加了它。

所有的功劳归功于Pyraego.com,我只是发布此信息以防其他人遇到同样的问题。

相关问题