그룹화 된 tableview의 머리글에 표시 할 문자열이 3 개 있습니다. 문제는이 문자열을 tableView titleForHeaderInSection
에 추가하고 각 문자열을 다른 색과 글꼴로 다른 줄에 표시하고 싶습니다.그룹화 된 머리글의 단어와 글꼴이 다릅니다. UItableview
현재 내가 가지고있는 것은 :
내가 원하는 것은 :
- (NSString *)tableView:(UITableView *)tableView titleForHeaderInSection: (NSInteger) section
{
NSString * presenter = [[self agenda] getBriefingPresenter:section];
NSString * time = [[self agenda] getBriefingTime:section];
NSString * subject = [[[[self agenda] getMeetingBriefings] objectAtIndex:section] objectForKey:@"subject"];
return [NSString stringWithFormat:@"%@\n%@ %@", subject, time, presenter ];
}
방법을 다음과 같은
내가 얻고 그 세 문자열을 추가 머리를 다루는 어 글꼴
- (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(45, 0, 484, 23);
label.textColor = [UIColor whiteColor];
label.font = [UIFont fontWithName:@"Century Gothic" size:17];
label.text = sectionTitle;
label.lineBreakMode = UILineBreakModeWordWrap;
label.numberOfLines = 2;
[label sizeToFit];
label.backgroundColor = [UIColor clearColor];
// Create header view and add label as a subview
UIView *view = [[UIView alloc] initWithFrame:CGRectMake(100, 300, 320, 400)];
[view addSubview:label];
return view;
}
그래서이 sectionTitle
을 분석하고 세 줄에 세 가지 다른 레이블로 인쇄 할 수 있습니까?
은 감사하지만, 필요하지 않습니다 나는'제거 할 때 - (있는 NSString *)있는 tableView : (jQuery과 *)있는 tableView titleForHeaderInSection : (NSInteger를) section' 제목 또는 머리글 영역이 0으로 줄어들고 간격이 없습니다. 그룹화 된 tableviews –
'- (CGFloat) tableView : (UITableView *) tableView heightForHeaderInSection : (NSInteger) section'의 서브 클래스를 만들고 적절한 높이를 반환하면됩니다. – nicolasthenoz
그냥 추가 '- (NSString *) tableView : (UITableView *) tableView titleForHeaderInSectio n : (NSInteger) 섹션 { return [NSString stringWithFormat : @ "\ n \ n \ n"]; }'작동하지만 나에게 좋은 해결책인지 모르겠다. –