John
John

Reputation: 29

How to increase the height of a section in a UItableview

How can I increase the height of a UITableView section. The code I am using right now is -

I tried to increase the height of the view that I am returning , but it does nothing . Can anyone help me?

-(UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section
{
    UIView *view = [[UIView alloc] initWithFrame:CGRectMake(0, 0, tableView.frame.size.width, 18)];
    /* Create custom view to display section header... */
    UILabel *label = [[UILabel alloc] initWithFrame:CGRectMake(10, 5, tableView.frame.size.width, 18)];
    [label setFont:[UIFont boldSystemFontOfSize:12]];

    NSString *string =[NSString stringWithFormat:@"%@  %@  %@",self.uploadYear[section],self.uploadDate[section],self.uploadTime[section]];

    [label setText:string];
    [view addSubview:label];
    [view setBackgroundColor:[UIColor colorWithRed:77/255.0 green:166/255.0 blue:147/255.0 alpha:1.0]]; //your background color...
    return view;
}

Upvotes: 0

Views: 1941

Answers (2)

Yagnesh Dobariya
Yagnesh Dobariya

Reputation: 2251

- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section{
   if(section==0){
        return 50.0f;
   }
   else if(section==1){
        return 60.0f;
   }
   else{
        return 100.f;
   }

}

Upvotes: 1

Reming Hsu
Reming Hsu

Reputation: 2225

add this delegate method

- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section;

in your case, return 18;

Upvotes: 4

Related Questions