【问题标题】:CALayer NAN deleting section of UITableView with custom UItableviewCellCALayer NAN 使用自定义 UItableviewCell 删除 UITableView 的部分
【发布时间】:2011-03-29 14:14:14
【问题描述】:

嗨,我不知道该往哪里看,我完全卡住了:

场景:当我离开视图的编辑模式时,我会删除表格的行和部分。 该表格由不同的自定义单元格组成,这些单元格在进入或离开时具有动画 编辑模式。

问题:有时,我不知道何时,我无法重现它,应用程序崩溃并显示“ CALayerInvalidGeometry', reason: 'CALayer position contains NaN: [nan 2.03571e-10]" 错误信息。

我现在找了几个小时,但我找不到错误,因此我提供了更多代码,也许有人知道它发生在哪里:

我调用 tis 方法将表格的编辑模式保留在其中 setupDetailEditMode 被调用。

- (void)setEditing:(BOOL)editing animated:(BOOL)animated {


if(editing)
{..}
else{

        tableShowEditMode = NO;
    [self setupDetailEditMode];

    [self createPersonTableHeader];
    [self clearAllEmptyFieldsFromArray];
        [self saveUserProfile];

        [super setEditing:editing animated:animated];
        [profileTable setEditing:editing animated:YES];
......}

此代码是我删除部分的地方......有些部分仍然有行,这没问题,因为它们将通过删除以下函数中的部分来删除,它会在最后一行崩溃:

part of function **setupDetailEditMode**:
   //Phone Section
    if(removedRowsPhone)

    {
        if(app.isitUserProfile.isitPhone.count == 0)
            [sectionOperationIndexSet addIndex:sectionWorked];

        sectionWorked++;
    }

    //Email Section 
    if(removedRowsEmail)
    {
        if(app.isitUserProfile.isitEmail.count == 0)
            [sectionOperationIndexSet addIndex:sectionWorked];

        sectionWorked++;
    }



    //update table data structur
    [self buildCurrentTableStructure];

    //delete sections <<<<<**here will crash the app sometimes**
    [profileTable deleteSections:sectionOperationIndexSet withRowAnimation:UITableViewRowAnimationFade]; 

我添加了一个我使用的随机自定义单元格,可能有问题导致 layoutsubviews 崩溃:

- (void) layoutSubviews {


    [super layoutSubviews];

    if (self.editing)
    {
        primaryField.enabled = YES;

        // (self.editing && !self.showingDeleteConfirmation)
        star1Img.frame = CGRectMake(87.0,30.0,20.0, 20.0);
        star2Img.frame = CGRectMake(111.0,30.0,20.0, 20.0);
        star3Img.frame = CGRectMake(135.0,30.0,20.0, 20.0);
        star4Img.frame = CGRectMake(159.0,30.0,20.0, 20.0);
        star5Img.frame = CGRectMake(183.0,30.0,20.0, 20.0);

        //primaryLabel.frame = CGRectMake(primaryLabel.frame.origin.x, 8.0,180.0 , 17.0);
        primaryField.frame = CGRectMake(primaryField.frame.origin.x, 8.0,180.0 , 17.0);
        secondaryLabel.frame = CGRectMake(secondaryLabel.frame.origin.x,18.0, 65.0 , 21.0);

    }
    else
    {
        primaryField.enabled = NO;

        star1Img.frame = CGRectMake(29.0,27.0,10.0, 10.0);
        star2Img.frame = CGRectMake(39.0,27.0,10.0, 10.0);
        star3Img.frame = CGRectMake(49.0,27.0,10.0, 10.0);
        star4Img.frame = CGRectMake(59.0,27.0,10.0, 10.0);
        star5Img.frame = CGRectMake(69.0,27.0,10.0, 10.0);

        primaryField.frame = CGRectMake(primaryField.frame.origin.x, 14.0,213.0 , 17.0);
        secondaryLabel.frame = CGRectMake(14.0,6.0, 65.0 , 21.0);
    }

} // layoutSubviews*/


- (void) setStarRating:(int) rating
{

    if(rating>=1)
        [star1Img setImage:[UIImage imageNamed:@"goldstar20.png"]];
......}

我对 atm 感到非常沮丧,因为我找不到这个错误,如果有人有提示或找到这个错误,那就太好了。任何事情都会有所帮助。谢谢

-贝沃

【问题讨论】:

    标签: iphone uitableview sections


    【解决方案1】:

    我没有仔细看过你的代码,但我曾经有过类似的东西。有一个视图已发布但确实想再次绘制 - 基本上是保留的东西。即使通过探查器也很难找到或理解。你应该用探查器检查是否有任何地方泄漏。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-02-24
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多