开发者

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 @"";
}
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜