iOS6 UITableView部分标题重复

时间:2013-04-04 09:06:23

标签: objective-c uitableview ios6

我在第4节中有一个带可扩展行的UITableView。当展开一行时,其他行需要折叠。我重新加载指定的行和滚动表以使扩展的行在顶部。这是代码:

    - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
    {
        [tableView deselectRowAtIndexPath:indexPath animated:YES];

        if (indexPath.section == 4)
        {
            if (indexPath.row == 0)
            {
                if (hypoExpanded)
                {
                    hypoExpanded = NO;

                    [self performSelector:@selector(reloadRowWithScrollForIndexPath:) withObject:indexPath afterDelay:kAnimationDelay];
                }
                else
                {
                    hypoExpanded = YES;
                    moodExpanded = NO;
                    activityExpanded = NO;

                    NSArray *indexArray = [NSArray arrayWithObjects:indexPath, [NSIndexPath indexPathForRow:1 inSection:4], [NSIndexPath indexPathForRow:2 inSection:4], nil];
                    [self performSelector:@selector(reloadRowWithScrollForIndexArray:) withObject:indexArray afterDelay:kAnimationDelay];
                } 

    ... }
}

- (void)reloadRowWithScrollForIndexArray:(NSArray *)indexArray
    {
        [self.tableView reloadRowsAtIndexPaths:indexArray withRowAnimation:UITableViewRowAnimationAutomatic];
        [self.tableView scrollToRowAtIndexPath:[NSIndexPath indexPathForRow:((NSIndexPath *)[indexArray objectAtIndex:0]).row inSection:((NSIndexPath *)[indexArray objectAtIndex:0]).section] atScrollPosition:UITableViewScrollPositionTop animated:YES];
    }


- (void)reloadRowWithScrollForIndexPath:(NSIndexPath *)indexPath
    {
        [self.tableView reloadRowsAtIndexPaths:[NSArray arrayWithObject:indexPath] withRowAnimation:UITableViewRowAnimationAutomatic];
        [self.tableView scrollToRowAtIndexPath:[NSIndexPath indexPathForRow:indexPath.row inSection:indexPath.section] atScrollPosition:UITableViewScrollPositionTop animated:YES];
    }


- (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section
{
    switch (section)
    {
        case 1:
            return [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"bgc-info"]];
            break;

        case 2:
            return [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"in-info"]];
            break;

        case 3:
            return [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"bp-info"]];
            break;

        case 4:
            return [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"per-info"]];
            break;
    }

    return nil;
}

有时,随机节标题(1,2或3)会重复并覆盖属于该节的单元格。滚动表格使该部分消失无济于事。当我向后滚动时,重复的标题仍然存在。 它只发生在iOS 6上。调用performSelectorOnMainThread:也没有帮助。此外,不调用scrollToRowAtIndexPath:一切正常。什么可能导致这种行为?

您可以在此处看到截图:

enter image description here

1 个答案:

答案 0 :(得分:0)

我遇到了同样的问题。检查代码中未提交的动画

[UIView beginAnimations:nil context:NULL];
... should be committed below