我将一个tableview添加到视图控制器,然后尝试在IOS 6.0中更改其节标题标题.
我将在每次调用特定函数时更改标题字符串,因此我不想处理 (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section
我尝试使用 (NSString *)tableView:(UITableView *)tableView titleForHeaderInSection:(NSInteger)section但是当我设置断点时,我发现它没有被调用.
在in.h文件中我添加了UITableViewDelegate,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;
} …Run Code Online (Sandbox Code Playgroud)