2012-02-21 2 views
0

그룹 스타일을 사용하여 UITableView를 만들었습니다. 내 테이블에는 단 하나의 그룹 만 있습니다. 여기 UITableView의 제목 머리글 옆에 이미지 추가

내 두 가지 질문은 다음과 같습니다

1) 어떻게 상단 헤더에 다음 내 제목에 사진을 표시합니까? 기본적으로 나는 그 회사의 로고를 그 타이틀 옆에 넣고 싶습니다.

2) 헤더의 배경색을 변경할 수 있습니까 (회색이 맘에 들지 않습니다). 헤더의 높이를 조정할 수 있습니까?

답변

0

은 그냥 헤더에이 방법으로 사용자 정의보기를 반환 :

//Draws a custom view for the header instructions 
-(UIView*)tableView:(UITableView*) tableView viewForHeaderInSection:(NSInteger)section; 
{ 
    if ([tableView numberOfRowsInSection:section] != 0) // To handle nil entries 
    { 
    UIView* headerView = [[[UIView alloc] initWithFrame:CGRectMake(0, 0, tableView.frame.size.width, 60)] autorelease]; 

     // set up whatever view you want here. E.g. 

    UILabel* headerLabel = [[UILabel alloc] initWithFrame:CGRectMake(10, 5, headerView.frame.size.width - 20.0, headerView.frame.size.height)]; 

     headerLabel.text = @"Tap items in the list to pin them.\nTap the Remix button to clear all unpinned items"; 
     headerLabel.numberOfLines = 0; 

    headerLabel.font = [UIFont fontWithName:@"HelveticaNeueLTStd-Lt" size: 14]; 
    headerLabel.backgroundColor = [UIColor clearColor]; 
    headerLabel.textColor = [UIColor colorWithRed:kColorRed green:kColorGreen blue:kColorBlue alpha:1]; 
    headerLabel.userInteractionEnabled = NO; 
     headerLabel.textAlignment = UITextAlignmentCenter; 

    headerView.backgroundColor = [UIColor clearColor]; 

    [headerView setTag:010]; 
    [headerView setAlpha:1]; 

    [headerView addSubview:headerLabel]; 
    [headerLabel release]; 
    return headerView; 
    } 
    else { 
     return nil; // again to handle nil tables. You should be nice and at least show an error label on the view. 
    }  
} 

을 그리고 이것은 다음과 같이 당신에게 뭔가를 제공합니다

How it should only work

+0

정말 고마워요 당신의 도움을. 메소드를 구현했지만 프로그램이 다운되었습니다. ARC를 사용하고 있으므로 모든 자동 복구 기능을 제거했습니다. – xcoderookie

+0

이후에 제대로 작동했는지 확인하십시오. 질문에 대한 해결책을 찾은 경우 체크 표시를 선택하십시오! – rinzler

관련 문제