I want to add a table header (not section headers) like in the contacts app for example:
exactly like that - a label beside an image above of the table.
I want the all view be scrollable so I can't place those outside of the table.
How can I do that?
If you have a single header in the table then you can use tableHeaderView as below: tableView. tableHeaderView = Header; Or if you have multiple header in table than you need to use Group table instead of plain table.
If you need to make the footer view fixed at the bottom then you can not use a TableViewController . You will have to use UIViewController , put your tableView as a subview. Put the footer also as another subview and its done.
UITableView
has a tableHeaderView
property. Set that to whatever view you want up there.
Use a new UIView
as a container, add a text label and an image view to that new UIView
, then set tableHeaderView
to the new view.
For example, in a UITableViewController
:
-(void)viewDidLoad { // ... UIView *headerView = [[UIView alloc] initWithFrame:CGRectMake(XXX, YYY, XXX, YYY)]; UIImageView *imageView = [[UIImageView alloc] initWithFrame:CGRectMake(XXX, YYY, XXX, YYY)]; [headerView addSubview:imageView]; UILabel *labelView = [[UILabel alloc] initWithFrame:CGRectMake(XXX, YYY, XXX, YYY)]; [headerView addSubview:labelView]; self.tableView.tableHeaderView = headerView; [imageView release]; [labelView release]; [headerView release]; // ... }
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With