Finding the best way to hide the search bar at the top of the window

I have several views where I want the search bar to be hidden if the user doesn't scroll to use it. I use this command to achieve this:

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

This works fine, but it is not perfect; at any time something happens that causes the table view to reload, it needs to be moved again.

Now I have a view where I want to completely hide the search bar from the user, that is, they can’t even scroll down to get to it, but I want the area bars at the top of the table. So basically, I want to scroll the search bar from the top of the view and save it there, leaving the visible part of the visibility bar. setContentOffset no longer does this for me, as the user can easily undo it.

Is there an approach to this that I skip?

Thanks in advance!

Update: I never thought about that, so in the end I changed my design.

+4
source share
1 answer

Although it is perhaps a little late when you say “something ever happens that causes the table view to reload, you need to move it again”, you say that every time your UITableView reloads it, it scrolls up? This is not standard UITableView behavior.

As for the second part of your question regarding your UISearchBar , I highly recommend replacing the UISearchBar with your own UISegmentedControl (after all, the entire UISearchBar area), so the user is not confused by the fact that there is an off-screen UISearchBar that does nothing.

+1
source

All Articles