I have a UITableView
set up on my app, which runs on iOS 7. I has one section and it loads images into custom cells and it scrolls under the navigation bar
as well, which is translucent. So initially, the content is below the navbar
and it scrolls under the navbar
as we scroll down to view more images. For this I have set an initial contentInset
of UIEdgeInsetsMake(40, 0, 0, 0)
. Now sometimes, I need a small header view on my table to indicate types of images on my table. So I have used the following code:
-(CGFloat) tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section{
return 30.0;
}
-(UIView*) tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section{
TableSectionHeader *header=[[[NSBundle mainBundle] loadNibNamed:@"TableSectionHeader" owner:self options:nil] objectAtIndex:0];
[header.title setText:[NSString stringWithFormat:@"Type: %@", self.imageType]];
return head;
}
Where TableSectionHeader
is custom view I have created for this purpose. Now ideally, the header must float or "stick" either just below the navbar
or at the top of the table (which is under the navbar). But in this case, it just rolls off screen. I want the header to stick right under the navbar
. Does anyone know how I can achieve this?