뷰 컨트롤러에 tableview를 추가 한 다음 IOS 6.0에서 섹션 헤더 제목을 변경하려고합니다.UITableView titleForHeaderInSection을 호출하지 않습니다.
내가 헤더 문자열을 특정 기능이 그래서 내가 (NSString *)tableView:(UITableView *)tableView titleForHeaderInSection:(NSInteger)section
을 사용하려고하지만 중단 점을 넣을 때이 호출되지 않는 것을 볼 수 (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section
처리 할 해달라고 호출 될 때마다 시간을 변경합니다. 내가 UITableViewDelegate를 추가
in.h 파일, UITableViewDataSource
in.m 내가 잘못 뭐하는 거지
-(void)viewDidAppear:(BOOL)animated
{
//tableview init
self.meetingList=[[UITableView alloc] initWithFrame:CGRectMake(10, self.ckCal.frame.origin.y + self.ckCal.bounds.size.height+20, 384, 450) style:UITableViewStylePlain];
[self.meetingList setSeparatorStyle:UITableViewCellSeparatorStyleNone];
self.meetingList.delegate=self;
//populate mutablearray for tableview here
[self eventsInThisMonth:[NSDate date]];
[self.view addSubview:self.meetingList];
}
-(void)eventsInThisMonth:(NSDate *)date
{
NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init];
[dateFormatter setDateFormat:@"MMMM , yyyy"];
//self.firstSectionHeader=nil;
self.firstSectionHeader= [NSString stringWithFormat:@"Events in %@", [dateFormatter stringFromDate:date]];
NSLog(@" self.firstSectionHeader %@ ",self.firstSectionHeader);
}
#pragma Tableview
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
return [self.eventHeaders count] + 1;
}
- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section
{
return 35;
}
//set header section labels
- (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section {
UIView *headerView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, tableView.bounds.size.width, 35)] ;
[headerView setBackgroundColor:[UIColor colorWithRed:106/256.0 green:106/256.0 blue:106/256.0 alpha:1.0]];
UILabel *subjectLabel = [[UILabel alloc] initWithFrame:CGRectMake(92, 10, tableView.bounds.size.width, 20)];
subjectLabel.textColor = [UIColor whiteColor];
subjectLabel.font = [UIFont fontWithName:@"Gill Sans" size:20];
subjectLabel.backgroundColor = [UIColor clearColor];
subjectLabel.text=self.firstSectionHeader;
NSLog(@"subjectLabel.text %@",subjectLabel.text);
if (section==0) {
//[headerView addSubview:subjectLabel];
return headerView;
}
else
return nil;
}
- (NSString *)tableView:(UITableView *)tableView titleForHeaderInSection:(NSInteger)section
{
if (section==0) {
NSLog(@"self.firstSectionHeader in titleForHeaderInSection %@",self.firstSectionHeader);
return self.firstSectionHeader;
}
else
return nil;
}
?
코드를 보면 ... 왜 viewForHeaderInSection과 titleForHeaderInSection을 모두 사용하고 싶습니까? 어쨌든 viewForHeaderInSection의 제목을 설정하고 있습니다 ... – Odrakir