To display a Headerview with an image and tags in the view controller

I am new to iPhone development. I created one view controller, and I used a grouped table view. Now I want to display the title view in my view manager with image and shortcuts. Please help me and help me in this problem.

Thanks.

+5
source share
1 answer

Do you mean the title or section of the HeaderView? You can add subviews to the headerView in the method viewDidLoad:

- (void)viewDidLoad {
    [super viewDidLoad];

    UILabel *label = [[UILabel alloc] initWithFrame:CGRectMake(10, 10, 300, 225)];
    label.text = @"BlaBla";
    [self.tableHeaderView addSubview:label];
}

initWithFrame subview tableHeaderView - .

Header, tableView:viewForHeaderInSection:, :

- (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section {
    UIView *view = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 320, 50)];

    UILabel *label = [[UILabel alloc] initWithFrame:CGRectMake(10, 10, 300, 40)];
    label.text = @"BlaBla";
    [view addSubview:label];
    [label release];

    return [view autorelease];
}

tableView:heightForHeaderInSection:, :

- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section {
    return 50.0f;
}
+3

All Articles