UITableView分隔符放置不正确

时间:2013-07-05 14:14:36

标签: uitableview cell separator

我正在使用动态UITable和原型单元格,它是在iOS 5的故事板中创建的。在此表格中,单元格高度取决于单元格的内容,并在heightForRowAtIndexPath中以编程方式进行评估。我的问题是,在显示的表中,单元格分隔符行放在错误的位置。以下是关于我的计划的一些事实:

  • 单元格内容和高亮显示在预期位置
  • 在cellForRowAtIndexPath中,我使用dequeueReusableCellWithIdentifier创建新单元格
  • heightForRowAtIndexPath返回所有单元格的正确值

任何人都可以帮我解决这个问题吗?我发现一个很老的线程在一年前讨论了同样的问题,但没有提出任何解释/解决方案(请参阅UITableView separators drawn incorrectly through cell reuse?

非常感谢您的帮助。

谢谢,

阿尼斯艾哈

1 个答案:

答案 0 :(得分:0)

感谢您回复我的帖子。这种行为对我来说也很奇怪,因为我之前有一个动态单元格高度表正常工作。以下是您要求的信息:

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    UITableViewCell *currentCell = nil;

    if([indexPath section] == 0 && [indexPath row]== 0)
    {
        currentCell = [issueDetailTable dequeueReusableCellWithIdentifier:@"DetailFieldCell"];

        NSString *summaryString;

        /* Here I call a method to figure out the value for summaryString */

        /* Here I call a method to figure out the frame for summaryLabel */

        summaryLabel = (UILabel *)[currentCell viewWithTag:1];
        [summaryLabel setFrame:summaryRect];
        [summaryLabel setText:summaryString];
    }
    return currentCell;
}

- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{    
    CGFloat height;

    if([indexPath section] == 0 && [indexPath row]== 0)
    {
        NSString *summaryString;

        /* Here I call the same method to figure out the value for summaryString */

        /* Here I call the same method to figure out the frame for summaryLabel */

        /* height = height of the summary label */
    }

    return height;
}

就故事板而言,我使用原型单元作为我的桌子;我的表自动调整大小并剪辑子视图并清除图形上下文;我的细胞清晰了图形背景。

并且,我将发布我的表视图的屏幕截图,但显然我的Stackoverflow信誉点是不够的! :|

再次感谢您帮助我解决这个问题。

最诚挚的问候, 茴香

相关问题