Reputation: 95
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
Upvotes: 6
Views: 13154
Reputation: 19333
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.
Upvotes: 6