UITableView tableView willDisplayHeaderView forSection
- (void)tableView:(UITableView *)tableView willDisplayHeaderView:(UIView *)view forSection:(NSInteger)section
Parameters of [UITableView tableView willDisplayHeaderView forSection]
tableView
The table-view object informing the delegate of this event.
view
The header view that is about to be displayed.
section
An index number identifying a section of tableView.
UITableView tableView willDisplayHeaderView forSection example.
- (NSString *)tableView:(UITableView *)tableView titleForHeaderInSection:(NSInteger)section {
if(section == 0)
return @"Countries to visit";
else
return @"Countries visited";
}
- (void)tableView:(UITableView *)tableView willDisplayHeaderView:(UIView *)view forSection:(NSInteger)section{
//displays the header of the tableView
self.tableView.tableHeaderView = view;
}
Example of [UITableView tableView willDisplayHeaderView forSection].
- (void) tableView:(UITableView *)tableView willDisplayHeaderView:(UIView *)view forSection:(NSInteger)section
{
DLog(@"0>>");
CGRect originalRect = view.frame;
UIImageView *imageView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"shadow_top.png"]];
[imageView setFrame:CGRectMake(0.0f, originalRect.size.height - imageView.frame.size.height, imageView.frame.size.width, imageView.frame.size.height)];
[view addSubview:imageView];
}
- (void) tableView:(UITableView *)tableView willDisplayFooterView:(UIView *)view forSection:(NSInteger)section
{
DLog(@"0>f>");
UIImageView *imageView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"shadow_bottom.png"]];
[imageView setFrame:CGRectMake(0.0f, 0.0f, imageView.frame.size.width, imageView.frame.size.height)];
[view addSubview:imageView];
}
{
DLog(@"0>>");
CGRect originalRect = view.frame;
UIImageView *imageView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"shadow_top.png"]];
[imageView setFrame:CGRectMake(0.0f, originalRect.size.height - imageView.frame.size.height, imageView.frame.size.width, imageView.frame.size.height)];
[view addSubview:imageView];
}
- (void) tableView:(UITableView *)tableView willDisplayFooterView:(UIView *)view forSection:(NSInteger)section
{
DLog(@"0>f>");
UIImageView *imageView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"shadow_bottom.png"]];
[imageView setFrame:CGRectMake(0.0f, 0.0f, imageView.frame.size.width, imageView.frame.size.height)];
[view addSubview:imageView];
}