Keep search bar fixed position while scrolling tab

2019-07-05 16:42发布

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

2条回答
倾城 Initia
2楼-- · 2019-07-05 17:14

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.

查看更多
SAY GOODBYE
3楼-- · 2019-07-05 17:37

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.

This should not be done to if u want the search bar not to scroll

enter image description here

查看更多
登录 后发表回答