How To Set Group Table's Section Header Text
I want to set header text for each section of my grouped UITableView.
I tried this code but get error "EXC_BAD_ACCESS"
- (NSString *)tableView:(UITableView *)tableView titleForHeaderInSection:(NSInteger)section
{
if (tableView.tag==2)
开发者_C百科 {
if (section == 0)
{
return @"test1";
}
if (section == 1)
{
return @"test2";
}
}
}
got it working, had to add return @"";
at the end for fail safe.
- (NSString *)tableView:(UITableView *)tableView titleForHeaderInSection:(NSInteger)section
{
if (tableView.tag==2)
{
if (section == 0)
{
return @"test1";
}
if (section == 1)
{
return @"test2";
}
}
return @"";
}
精彩评论