Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ios/99.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
有时在UITableView中删除行时崩溃(仅在iOS7中)_Ios_Uitableview - Fatal编程技术网

有时在UITableView中删除行时崩溃(仅在iOS7中)

有时在UITableView中删除行时崩溃(仅在iOS7中),ios,uitableview,Ios,Uitableview,我的应用程序在iOS6中运行得很酷,但当我使用与我使用的代码相同的代码更新iOS7时,当我尝试删除表中的一行时,会出现以下错误: UIViewAnimation initWithView:indexPath:endRect:endAlpha:startFraction:endFraction:curve:animateFromCurrentPosition:shouldDeleteAfterAnimation:editing: 下面的代码就是这样的 - (void)tableView:(UIT

我的应用程序在iOS6中运行得很酷,但当我使用与我使用的代码相同的代码更新iOS7时,当我尝试删除表中的一行时,会出现以下错误:

UIViewAnimation initWithView:indexPath:endRect:endAlpha:startFraction:endFraction:curve:animateFromCurrentPosition:shouldDeleteAfterAnimation:editing:
下面的代码就是这样的

- (void)tableView:(UITableView *)sender commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath {

    if (editingStyle == UITableViewCellEditingStyleDelete) {
        // Delete the row from the data source.

        [self.tableView beginUpdates];
        PACallLog *aLog = _logs[indexPath.row];
        [[PAFMDBManager sharedManager] deleteACallLog:aLog];
        [_logs removeObjectAtIndex:indexPath.row];
        [self.tableView deleteRowsAtIndexPaths:[NSArray arrayWithObject:indexPath] withRowAnimation:UITableViewRowAnimationAutomatic];
        [self.tableView endUpdates];

    }
}
在ViewDidDisplay方法中,logsarray从db获取值,因此当我删除行时,我应该 1.从数据库中删除数据 2.从日志中删除对象 3.执行deleteRowsAtIndexPaths方法

但有时我在IOS7中删除行时会崩溃 有人能帮我吗

事故日志:

Last Exception Backtrace:
0   CoreFoundation                  0x3065ae7e __exceptionPreprocess + 126
1   libobjc.A.dylib                 0x3a9b76c2 objc_exception_throw + 34
2   CoreFoundation                  0x3065ad50 +[NSException raise:format:arguments:] + 100
3   Foundation                      0x310030aa -[NSAssertionHandler         handleFailureInMethod:object:file:lineNumber:description:] + 86
4   UIKit                           0x32fdc8ce -[UIViewAnimation initWithView:indexPath:endRect:endAlpha:startFraction:endFraction:curve:animateFromCurrentPosition:shouldDeleteAfterAnimation:editing:] + 350
5   UIKit                           0x32fe020e -[_UITableViewUpdateSupport(Private) _setupAnimationsForExistingHeadersAndFooters] + 5278
6   UIKit                           0x32fda7d6 -[_UITableViewUpdateSupport _setupAnimations] + 182
7   UIKit                           0x32fda286 -[UITableView _updateWithItems:updateSupport:] + 1358
8   UIKit                           0x32fb2392 -[UITableView _endCellAnimationsWithContext:] + 8014
9   2cu                             0x00137a14 0x4000 + 1260052
10  UIKit                           0x32fd87c2 -[UITableView animateDeletionOfRowWithCell:] + 90
11  UIKit                           0x32fd8754 -[UITableViewCell _swipeDeleteButtonPushed] + 60
12  UIKit                           0x32e13d9e -[UIApplication sendAction:to:from:forEvent:] + 86
13  UIKit                           0x32e13d3a -[UIApplication sendAction:toTarget:fromSender:forEvent:] + 34
14  UIKit                           0x32e13d0e -[UIControl sendAction:to:forEvent:] + 42
15  UIKit                           0x32dff73e -[UIControl _sendActionsForEvents:withEvent:] + 370
16  UIKit                           0x32e13756 -[UIControl touchesEnded:withEvent:] + 590
17  UIKit                           0x32e13420 -[UIWindow _sendTouchesForEvent:] + 524
18  UIKit                           0x32e0e44c -[UIWindow sendEvent:] + 828
19  UIKit                           0x32de3d74 -[UIApplication sendEvent:] + 192
20  UIKit                           0x32de2564 _UIApplicationHandleEventQueue + 7112

删除行后,可以再次重新加载tableview。在代码中添加此语句。 [tableview重新加载数据]

它在工作
- (void)tableView:(UITableView *)sender commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath {

    if (editingStyle == UITableViewCellEditingStyleDelete) {
        // Delete the row from the data source.

        [self.tableView beginUpdates];
        PACallLog *aLog = _logs[indexPath.row];
        [[PAFMDBManager sharedManager] deleteACallLog:aLog];
        [_logs removeObjectAtIndex:indexPath.row];
        [self.tableView deleteRowsAtIndexPaths:[NSArray arrayWithObject:indexPath] withRowAnimation:UITableViewRowAnimationAutomatic];
        [self.tableView endUpdates];

        // Refill your array and table reload

    }
}
在CommittedItingStyle方法的末尾添加这一行,这将帮助您解决问题

[TableView deleteRowsAtIndexPaths:[NSArray arrayWithObject:indexPath] withRowAnimation:UITableViewRowAnimationFade];

你能粘贴准确的崩溃报告吗?请将崩溃日志放到帖子中,这样我们就可以告诉你问题和解决方案。当然,我会更新错误日志,当然,我可以使用重新加载表视图,但我丢失了删除单元格的动画