嗨,我不知道在哪里看我完全卡住了:
场景:当我离开视图的编辑模式时,我删除了表格的行和部分。该表由不同的自定义单元格组成,这些单元格在进入或离开编辑模式时具有动画效果。
问题:有时我不知道何时无法重现,应用程序崩溃并显示“CALayerInvalidGeometry”,原因:“CALayer 位置包含 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 感到非常沮丧,因为我找不到这个错误,如果有人有提示或找到这个错误,那就太好了。任何事情都会有所帮助。谢谢
-贝沃