UISearchBar on the top of UITableView which can hide but stay close to UINavigationBar

后端 未结 4 1676
猫巷女王i
猫巷女王i 2020-12-14 20:37

I would like to have a UISearchBar on the top of my UITableView which hides when you scroll down: The answer is easy, I just need to add it on my table view

4条回答
  •  悲哀的现实
    2020-12-14 21:28

    You will need to hide the search bar on your own when you scroll the tableview. So, don't put it as a UITableView header. You could hide it by setting its height to zero. That way if your tableview is set to autoresize it will expand.

    I would experiment with having the UITableView and the UISearchBar as peers within another view. The GameCenter image does not have the search bar as the table view header, rather it has them as separate subviews.

    You could also look at UISearchDisplayController but I think it doesn't quite have the behaviour that you want.

    Edit: This question is basically your question and has some code in the answers.

提交回复
热议问题