如上圖,在第一個section它的頭部比其他section大,只是為何?如何解決?
相關代碼
- (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section
{
NSString *sectionTitle = [self tableView:tableView titleForHeaderInSection:section];
if (sectionTitle == nil) {
return nil;
}
// Create label with section title
UILabel *label = [[UILabel alloc] init];
label.frame = CGRectMake((SCREEN_WIDTH-200)/2, 10, 200, 25);
label.backgroundColor = [UIColor clearColor];
label.textColor = BarCOLOR;
label.font = [UIFont fontWithName:@"Helvetica-Bold" size:14];
label.textAlignment = NSTextAlignmentCenter;
label.text = sectionTitle;
// Create header view and add label as a subview
UIView *sectionView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, tableView.bounds.size.width, 22)];
[sectionView setBackgroundColor:[UIColor blackColor]];
[sectionView addSubview:label];
return sectionView;
return nil;
}
-(NSString *)tableView:(UITableView *)tableView titleForHeaderInSection:(NSInteger)section
{
return @"12232211";
}
(CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section
{
return 22;
}
(CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section
{
return 0.1;
}