删除uitableview单元格时断言失败

时间:2014-03-09 15:00:57

标签: ios uitableview uiviewanimation assertions

我选择时会删除tableview中的单元格。每个单元格代表它自己的部分,所以我将它们删除如下

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{

    [self.myData removeObjectAtIndex:indexPath.section];
    [self.tableView beginUpdates];
    [self.tableView deleteSections:[NSIndexSet indexSetWithIndex:indexPath.section] withRowAnimation:UITableViewRowAnimationAutomatic];
    [self.tableView endUpdates];
}

但有时 - 并非总是 - 我收到此错误

*** Assertion failure in -[UIViewAnimation initWithView:indexPath:endRect:endAlpha:startFraction:endFraction:curve:animateFromCurrentPosition:shouldDeleteAfterAnimation:editing:], /SourceCache/UIKit/UIKit-2903.23/UITableViewSupport.m:2661

不明白原因......

这是tableview及其图层

的转储
Printing description of self->_tableView:
<UITableView: 0x17043200; frame = (20 40; 280 160); clipsToBounds = YES; autoresize = W+H; gestureRecognizers = <NSArray: 0x16653330>; layer = <CALayer: 0x166dbc70>; contentOffset: {0, 35}>
(lldb) po 0x166dbc70
<CALayer:0x166dbc70; position = CGPoint (160 120); bounds = CGRect (0 35; 280 160); delegate = <UITableView: 0x17043200; frame = (20 40; 280 160); clipsToBounds = YES; autoresize = W+H; gestureRecognizers = <NSArray: 0x16653330>; layer = <CALayer: 0x166dbc70>; contentOffset: {0, 35}>; sublayers = (<CALayer: 0x1667f320>, <CALayer: 0x16556400>, <CALayer: 0x16763220>, <CALayer: 0x165d8440>, <CALayer: 0x1662d260>, <CALayer: 0x1674e010>); masksToBounds = YES; allowsGroupOpacity = YES; backgroundColor = <CGColor 0x1668ef70> [<CGColorSpace 0x166868e0> (kCGColorSpaceDeviceGray)] ( 0 0 )>

0 个答案:

没有答案