当我从表中删除行时,我的应用程序崩溃了.以下是检测到错误和堆栈跟踪的源代码.感谢名单!
//delete row from database
- (void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath
{
NSLog(@"\ncommitEditingStyle");
//delete user from Users table with specified ID
if(editingStyle == UITableViewCellEditingStyleDelete)
{
//Get the object to delete from the array.
[dbManager open: @DB_FILE_NAME];
//get userID from array usersIDList[row] = userID!
NSNumber *usersID = [usersIDList objectAtIndex: [indexPath row]];
[dbManager deleteUserWithID: [usersID intValue] table: @TABLE_USERS fieldName: @"UserID" ];
[dbManager close];
//Delete the object from the table.
[self.tableView deleteRowsAtIndexPaths:
[NSArray arrayWithObject: indexPath]
withRowAnimation: UITableViewRowAnimationFade];
}
}
- (void)deleteRowsAtIndexPaths:(NSArray *)indexPaths withRowAnimation:(UITableViewRowAnimation)animation …Run Code Online (Sandbox Code Playgroud) 我写了一段代码
[self.pItemArray insertObject:breakingItem atIndex:0];
NSArray *array = [NSArray arrayWithObject:[NSIndexPath indexPathForRow:0 inSection:0]];
[self.pTable beginUpdates];
[self.pTable insertRowsAtIndexPaths:array withRowAnimation:UITableViewRowAnimationNone];
[self.pTable endUpdates];
Run Code Online (Sandbox Code Playgroud)
但它只在endUpdtes上的ios 8中崩溃.
断言失败 - [UITableView _endCellAnimationsWithContext:],/ SourceCache/UIKit/UIKit-3302.3.1 /UITableView.m:1581
它在ios7或更低版本中工作正常.
请帮忙.