こんにちは、どこを調べればいいのかわかりません。完全に立ち往生しています。
シナリオ: ビューの編集モードを終了すると、テーブルの行とセクションが削除されます。テーブルは、編集モードに入るときまたは終了するときにアニメーションを持つさまざまなカスタム セルで構成されます。
問題: ときどきわかりませんが、再現できません。アプリがクラッシュし、「CALayerInvalidGeometry」、理由:「CALayer の位置に NaN が含まれています: [nan 2.03571e-10]」というエラー メッセージが表示されます。
私は何時間も探しましたが、エラーが見つからないため、エラーが発生した場所を誰かが知っているかもしれないコードをさらに提供します:
setupDetailEditMode が呼び出されると、テーブルの編集モードを終了するために tis メソッドを呼び出します。
- (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];
レイアウトサブビューでクラッシュを引き起こす何か問題がある可能性があるため、使用するランダムなカスタムセルを追加します。
- (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"]];
......}
私はこのバグを見つけることができないので、非常にイライラしています. 何でも役に立ちます。ありがとう
-ベボ