CALayer NAN 使用自定义 UItableviewCell 删除 UITableView 的部分
嗨,我不知道在哪里进一步查看,我完全陷入困境:
场景:当我离开视图的编辑模式时,我删除了表格的行和部分。 该表格由不同的自定义单元格组成,这些单元格在进入或离开时有动画 编辑模式。
问题:有时,我不知道什么时候,我无法重现它,应用程序崩溃并显示“ 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,因为我找不到这个错误,它会如果有人有提示或发现错误,请非常友善,谢谢
-Bevo 。
Hi i dont know where to look further im totally stuck:
Scenario: When i leave edit mode of my view i delete rows and sections of my table.
The table consits of different custom cells which have animation when entering or leaving
editmode.
Problem: Sometimes and i dont know when, i cant reproduce it, the app crashes with a "
CALayerInvalidGeometry', reason: 'CALayer position contains NaN: [nan 2.03571e-10]" error message.
I looked for hours now but i cant find the error therefor i provide some more code maybe anyone knows where it happens:
I call tis method to leave edit mode of the table in it setupDetailEditMode gets called.
- (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];
......}
This code is where i delete sections.... some of the sections still have rows which is no problem cause they will be deleted by deleting the section in the following function it crashes last line:
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];
I add a random custom cell i use maybe there is something wrong that causes the crash in 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"]];
......}
I am very frustrated atm because i cant find this bug it would be very niice if anyone has a hint or find the bug. Anything will help. Thanks
-Bevo
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我没有仔细查看你的代码,但我曾经有过类似的经历。有一个视图已发布,但确实想再次绘制 - 基本上是一个保留的东西。即使通过探查器也很难找到或理解。您应该使用探查器检查是否有任何地方泄漏。
I haven't looked through your code very much, but I had something similar once. There was a view that got released but did want to be painted again - basically a retain thing. Hard to find - or understand - even via profiler. You should check with the profiler if there is a leak anywhere.