2011-10-16 4 views
2

감싸기 및/또는 스크롤 할 UITable보기의 섹션 헤더에있는 텍스트를 가져 오려고합니다.텍스트 줄 바꾸기 또는 UITableView 섹션 헤더 스크롤 방법?

나는이 시도했다 :

// support line break mode for multiline 
headerLabel.lineBreakMode = UILineBreakModeWordWrap; 

// 0 means any number of lines - necessary for multiline 
headerLabel.numberOfLines = 0; 

// fit the text 
[headerLabel sizeToFit]; 

하지만 행운.

제안 사항?

답변

0

레이블이 표시되는 한, 작동시키기 위해서 필요한 모든 것입니다. 하나의 질문/제안, 당신은 tabView의 – tableView:viewForHeaderInSection: 방법, 오른쪽의 레이블을 이렇게하고있다?

1

viewForHeaderInSection이 샘플로 시험 인쇄를 해보십시오 :

UIView* customView = [[UIView alloc] init]; 
UILabel * headerLabel = [[UILabel alloc] initWithFrame:CGRectZero]; 
headerLabel.backgroundColor = [UIColor clearColor]; 
headerLabel.opaque = YES; 
headerLabel.textColor = [UIColor whiteColor]; 

headerLabel.highlightedTextColor = [UIColor whiteColor]; 

headerLabel.shadowColor = [UIColor colorWithRed:0.0f/255.0f green:0.0f/255.0f blue:0.0f/255.0f alpha:0.25f]; 
headerLabel.shadowOffset = CGSizeMake(0.0f, -1.0f); 

headerLabel.font = [UIFont boldSystemFontOfSize:16]; 
headerLabel.frame = CGRectMake(10.0, 0.0, 232.0,40.0); 

headerLabel.numberOfLines=2; 
headerLabel.text=[self.keys objectAtIndex:section]; 

[customView setBackgroundColor:[UIColor colorWithRed:0.64f green:0.68f blue:0.72f alpha:1.0f]]; 
[customView addSubview:headerLabel]; 

return customView; 
2

당신이

-(CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section

를 사용하여 헤더의 높이를 설정해야합니다
관련 문제