I have a tableView with a searchBar inside the table header.
Everything is working well except when I scroll down the rows, the search bar disappear.
How can I make it fixed?
There is no a way to maintain the header of a tableView fixed, but an useful approach when you need a unique header, could be to use UIViewController instead of UITableViewController, and set the header (UIView that contains searchBar) above the tableView.
Related
I am working on Table View. I have implemented Header at the top of TableView. Its scrolling when i scroll TableView. Any Solution to make the Header Static.
If you want a static header, it means that it should not be a header. The behaviour of a header is to scroll with the UITableView.
You can replace it with an UIView placed above your UITableView.
Also, you can use the UITableView.headerView (UIView?), this is a view placed at the top end of the whole tableView and not per section as the sectionHeaderView.
You can simply add UIView On top of UITableView.
Like this :
And result will be:
I want to add buttons that are static (they do not scroll with the Tableview) above the Tableview, but below the navigation bar. As described in this question
How to place buttons above UITableView (and not in navigation bar)?
The answer seems to be just use a UITableView, but is there a way of doing it with using a UITableViewController? or you have to use a UITableView and just make it smaller and put buttons above?
You can add buttons in a tableView in any case: just use the HEADER of the tableView.
In details the property is tableHeaderView, and add a view on top of the table.
By the datasource of the tableView you can also return an headerView for any section.
Apple Documentation
I'm using a UITableViewController, and with 2 sections.
One section does use a Header and the other one doesn't.
The header view of one section, has an UITextField, an UIButton and an UISegmentedControl, all with AutoLayout using PureLayout Framework.
When I scroll, the Header view stays fixed in the top (just as a normal header would do).
Now, When I click on the Button, I call a method to update an User, (taking the text from the UITextField) and as soon as I get the data, I reload the data from the table.
It is here, when the UIView used as a Header, jumps to the top of the screen, or if it's fixed on the top, disappears until I move the table the Header appears correctly.
Don't know what really it's happening, any ideas guys?
Thanks!
Try to add in viewDidLoad: self.automaticallyAdjustsScrollViewInsets = NO;
I have issue when in header was an image, and when i scroll header remain, but table content goes under it. I solve this issue with change style from Plain to Grouped. But i think this is does't help you, but maybe...Also check your creating tableView cells, if it they're custom - register nib of cell in viewDidLoad.
I have a UITableView with one section and a header. The problem is that when I scroll down beyond the contents of the table, the header is pulled down along with the cells. I would like it to stay at the top of the view. I tried the suggestion on this post,
Change Default Scrolling Behavior of UITableView Section Header
using the footer of a zero-row section as the header, but it still isn't anchored. Does anyone know how to do this properly?
Are you using a UITableViewController? If you are using a UIViewController that contains a UITableView you could just add a UIView above the UITableView.
You could also add the UIView on top of the UITableView and add an alpha gradient to make it look more similar to a regular UITableView section header.
I have a UITableView with Headers and Rows. When the Rows scroll up into the Header section it looks like they scroll behind the Header. This is fine except I want both my Header and Rows to have non opaque alpha. The design is translucent. When this is the case you can see the Row scroll behind the Header which is bad. Ideally the row just disappears when it scrolls into the Header section.
Anyone have a solution that will still allow me to use translucent Headers? Thanks!
I had the same issue.
If you only have one header the easy solution I did was to just take the header label out of the tableview and put it in the parent view of the uitableview and just shift the uitableview to compensate for the new header view. Now make the header view transparent and the rows don't scroll behind the header view because it is in a different. The downside is that when you scroll up the header doesn't float above the next cell and obviously it doesn't work for multiple headers. Hope this helps.