Keep search bar fixed position while scrolling tableView

一个人想着一个人 提交于 2019-12-13 14:03:43

问题


How can i keep the uiSearch bar i created in Xcode 4.3.3 fixed on top while scrolling the table view? Any thoughts?


回答1:


EDITED: If u have used the Interface builder to add the search bar, make sure that it is not added as the subview of the tableview (this makes the search bar as a part of the table, which scrolls along with the table). Checkout the link below, and avoid it. This link shows how a search bar becomes a subview of the table. This is not what u want. Just drag the search bar outside of the Table view in ur interface builder, so that it becomes a part of the view.

I have added second image to show how u can find the solution to ur problem.

If u want to add the search bar programatically, then just add it as-

[self.view addSubview:mySearchBar];

Set the frame of this search bar accordingly.




回答2:


how did you create them in the nib file? do not put the search bar on the UITableView. they should be separated.You can put the search bar at the top of the tableview but not on it.



来源:https://stackoverflow.com/questions/11902213/keep-search-bar-fixed-position-while-scrolling-tableview

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!