Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to disable UITableView header scroll?

I created a UITableView programmatically and now I want to add a fixed header to it. As I the below code the header also scrolls with my tableview.

    UILabel *label = [[[UILabel alloc] 
    initWithFrame:CGRectMake(0, 0, 320, 28)] autorelease];

    label.backgroundColor = [UIColor darkGrayColor];
    label.font = [UIFont boldSystemFontOfSize:15];
    label.shadowColor = [UIColor colorWithWhite:0.0 alpha:0.8];
    label.textAlignment = UITextAlignmentLeft;
    label.textColor = [UIColor whiteColor];
    label.text = @"my header";

    myTable.tableHeaderView = label;

Is there a function which disables header scrolling?

Thank you

like image 715
bugphix Avatar asked Feb 20 '11 16:02

bugphix


People also ask

How to disable floating headers in UITableView?

To disable floating but still show section headers you can provide a custom view with its own behaviours. Show activity on this post. Another way to do it is to make an empty section right before the one you want the header on and put your header on that section.

What is Uitableview in Swift?

A view that presents data using rows in a single column.


1 Answers

No, you need to either change the view to be a section header (where it will remain at the top of the tableview while that section is visible), or you need to make the header view a sibling to the tableview in the tableview's superview -- you can create a UIView just for the purpose of holding the header view and the table view.

like image 71
Bogatyr Avatar answered Oct 23 '22 03:10

Bogatyr