Frage

I have a tableview with a search bar. All is working fine but now I want a button to hide/show the search bar. This functionality is what my question is about.

Now I have created a bar below the screen where I have created a button for this. In code, there is a void function which can be filled with the code I am looking for. Just to give you an impression of how the code looks like. Right now it is empty.

I've done some research and I came up with bringSubViewToFront and sendSubViewToBack, HeadsUpUI sample app. The idea I had was that I could show the search bar by bringing it to front, put OVER the table view layer, while setting the tableview 44 pixels lower with content offset or so.

Likewise, sending the search bar layer to back, BEHIND the table view to hide it. So in the void function I tried something with [parentview sendSubViewToBack:child view] but to no effect. So my question is: how do I hide or show my search bar while having a table view and a navigation bar and a bar below with the button to do so?

Kind Regards,

John

War es hilfreich?

Lösung

Use like -

childview.hidden = YES;

EDIT 1-

childview.hidden = YES;
[parentview sendSubViewToBack:childview];
[tableView reloadData];

Hope it work for you.

Andere Tipps

You can use IBOutlate to your searchBar and then use this outlate to show or hide the search bar

Also don't forget to connect it with your searchBar in xib

Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top