2009-10-05 2 views

답변

2

헤더는 반환 뷰가 jQuery과 (OS 3.1.2 이상이 문제를 표시하는 것)에 의해 유지되지 않도록 조심하십시오. 이로 인해 실행이 viewDidLoad에 도착하기 전에 발생하는 찾기 힘든 충돌이 발생합니다.

테이블보기는 필요에 따라보기를 가져 오지 않습니다. 그것들을 모두 요청한 다음, 다시 요청하고 때로는 여러 번 요청하기 때문에 요청할 때마다 생성하는 것은 매우 비효율적입니다.

2

사용 tableView:viewForHeaderInSection:. 그렇게하면 UILabel 또는 무엇이든간에 (글꼴, 투명도, 색상 등으로 완성 된) UILabel을 구성 할 수 있으며, tableview는 기본보기와 대조하여 해당보기를 머리글로 사용합니다.

5

당신은 folowing 시도 할 수 있습니다 : 두 개의 사용자 정의 라벨

- (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection: 
                 (NSInteger)section { 
    UIView *headerView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 
    tableView.bounds.size.width, 22)]; 

    NSString *dateStr = [[self.data allKeys] objectAtIndex:section]; 
    CGFloat labelWidth = tableView.bounds.size.width/2; 
    CGFloat padding = 5.0; 

    UILabel *labelOne = [[UILabel alloc] initWithFrame:CGRectMake 
         (padding, 0, (labelWidth - padding), 22)]; 
    labelOne.backgroundColor = [UIColor clearColor]; 
    labelOne.textAlignment = UITextAlignmentLeft; 
    labelOne.text = dateStr; 

    UILabel *labelTwo = [[UILabel alloc] initWithFrame:CGRectMake 
    (labelWidth, 0, (labelWidth - padding), 22)]; 
    labelTwo.backgroundColor = [UIColor clearColor]; 
    labelTwo.textAlignment = UITextAlignmentRight; 
    labelTwo.text = @"This is Label TWO"; 

    [headerView addSubview:labelOne]; 
    [headerView addSubview:labelTwo]; 

    [labelOne release]; 
    [labelTwo release]; 

    return headerView; 
} 
1

당신의 jQuery과 헤더의 색상을 변경 & 코드를 다음 사용하시기 바랍니다

-(UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section 
{ 
    UIView *tempHeaderView=[[UIView alloc]initWithFrame:CGRectMake(0,0,320,44)]; 
    tempHeaderView.backgroundColor=[UIColor clearColor]; 
    UILabel *tempHeaderLabel=[[UILabel alloc]initWithFrame:CGRectMake(0,0,320,44)]; 
    tempHeaderLabel.backgroundColor=[UIColor clearColor]; 
    [email protected]"HEADER"; 
    [tempHeaderView addSubView: tempHeaderLabel]; 
    return tempHeaderView; 
} 
관련 문제