2015-06-12 90 views
0

如何增加UITableView节的高度。我现在使用的代码是 -如何在UItableview中增加节的高度

我试图增加视图的高度,但我没有做任何事情。 任何人都可以帮助我吗?

-(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; 
} 
+0

'的tableView:heightForHeaderInSection:'? – Larme

回答

1

添加此委托方法

- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section; 
你的情况

return 18;

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

}