繁体   English   中英

iOS 8 UITableView中的奇怪问题

[英]Strange issue in iOS 8 UITableView

我有一个UITableView ,在Master-Detail结构中具有自定义UITableViewCell 表格的单元格可以是文档或文件夹...如果一个单元格是一个文档,它将在详细信息视图中打开文档,但是如果是一个文件夹,则将在下面打开其他单元格。 这在iOS 7上完美运行,但是在iOS 8上运行时,当我点击一个单元格时,我的应用程序冻结,并且占用了越来越多的内存...最后,它崩溃了。 我已经尝试了一切...我已经搜索了一切...似乎什么都没用!

这是我的didSelectRowAtIndexPath:方法

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
    NSLog(@"OBJECTS: %lu", (unsigned long)_objects.count);
    [tableView deselectRowAtIndexPath:indexPath animated:YES];
    NSDictionary *d=[_objects objectAtIndex:indexPath.row];
    if([d valueForKey:@"Objects"])
    {
        NSArray *ar=[d valueForKey:@"Objects"];
        BOOL isAlreadyInserted=NO;
        for(NSDictionary *dInner in ar )
        {
            NSInteger index=[_objects indexOfObjectIdenticalTo:dInner];
            isAlreadyInserted=(index>0 && index!=NSIntegerMax);
            if(isAlreadyInserted) break;
        }
        if(isAlreadyInserted)
        {
            [self miniMizeThisRows:ar];
        }
        else
        {
            NSUInteger count=indexPath.row+1;
            NSMutableArray *arCells=[NSMutableArray array];
            for(NSDictionary *dInner in ar )
            {
                [arCells addObject:[NSIndexPath indexPathForRow:count inSection:0]];
                [_objects insertObject:dInner atIndex:count++];
            }

            [self addRowsAtIndexPaths:arCells];
        }
    }
    else
    {
        NSDictionary *object = [_objects objectAtIndex:indexPath.row];
        self.detailViewController.detailItem = [object objectForKey:@"name"];
        self.detailViewController.title = [object objectForKey:@"displayedName"];

        if(![cache containsObject:object])
        {
            TableCustomCell *cell = (TableCustomCell*)[tableView cellForRowAtIndexPath:indexPath];
            [cell.marker setHidden:NO];

            [cache addObject:object];
        }
    }
}

在addRowsAtIndexPaths中:

- (void)addRowsAtIndexPaths:(NSArray*)indexPaths
{
    [self.tableView beginUpdates];
    [self.tableView insertRowsAtIndexPaths:indexPaths withRowAnimation:UITableViewRowAnimationMiddle];
    [self.tableView endUpdates];
}

有人帮忙???

谢谢。

编辑

我发现循环是由我的UITableViewCell sublcass引起的...我使用以下代码来管理缩进:

- (void)layoutSubviews
{
    [super layoutSubviews];

    float indentPoints = self.indentationLevel * self.indentationWidth;

    self.contentView.frame = CGRectMake(indentPoints,
                                        self.contentView.frame.origin.y,
                                        self.contentView.frame.size.width - indentPoints,
                                        self.contentView.frame.size.height);
}

通过评论此内容,该应用程序可以正常工作...但是单元格没有缩进!

在冻结期间,尝试在调试器上按“暂停”按钮,然后在callStack上查看,然后按“继续”按钮,再按“暂停”,然后查找调用,它们之间是一样的。 看起来像通话周期。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM