开发者

Looking for a better way to hide search bar at top of view

I have several views where I want the search bar to be hidden开发者_Python百科 unless the user scrolls it down to use it. I use this command to achieve this:

[self.tableView setContentOffset:CGPointMake(0, 44) animated:NO];

This works ok, but it's not ideal; any time something happens that causes the table view to reload, it has to be repositioned again.

Now I have a view where I want to completely hide the search bar from the user, meaning they can't even scroll down to get to it, but I want to keep the scope bars at the top of the table. So basically I want to scroll the search bar off the top of the view and keep it there, while leaving the scope bar portion of the control visible. setContentOffset isn't doing it for me anymore, since the user can easily undo it.

Is there an approach to this that I'm overlooking?

Thanks in advance!

Update: I never figured this out, so ultimately I changed my design.


Although it's probably a bit late, when you say "any time something happens that causes the table view to reload, it has to be repositioned again", are you saying that every time your UITableView reloads it scrolls to its top? This isn't the standard behaviour of a UITableView.

In regards to the second part of your question regarding your UISearchBar's scope, I'd strongly recommend replacing the UISearchBar with your own UISegmentedControl (that's all the scope of a UISearchBar is anyway), so that the user isn't confused by there being an off-screen UISearchBar that doesn't do anything.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜