我有点卡住尝试创建自定义ios表头.我的标题是30px高,我使用此代码来创建它们: 
  
  
 
- (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(0,140,30);
    label.backgroundColor = [UIColor colorWithPatternImage:[UIImage imageNamed:@"header_gradient.png"]];
    label.textColor = [UIColor whiteColor];
    label.shadowColor = [UIColor whiteColor];
    label.shadowOffset = CGSizeMake(0.0,1.0);
    label.font = [UIFont boldSystemFontOfSize:12];
    label.text = sectionTitle;
    // Create header view and add label as a subview
    UIView *view = [[UIView alloc] initWithFrame:CGRectMake(0,30)];
    [view addSubview:label];
    return view;
}
- (CGFloat)tableView:(UITableView *)tableViewheightForHeaderInSection:(NSInteger)section {
    return 30;
} 
 它几乎可以工作,但我的标题似乎与它们下面的单元格/标题相符:
有人能指出我在清理标题的正确方向吗?
提前致谢
解决方法
 你错过了[空间]: 
  
 
        你有:
- (CGFloat)tableView:(UITableView *)tableViewheightForHeaderInSection:(NSInteger)section { 
 它应该是:
- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section {