应用程序崩溃在tableview的reloadData方法
我的应用程序在调用方法[tableView reloadData]
表视图后崩溃。这发生在删除单行tableview(具有表视图默认删除行为)并调用[tableView reloadData]
,然后在此代理numberOfSectionsInTableView
应用程序崩溃并显示我崩溃消息[UITableViewCell _setDeleteAnimationInProgress : ] : message sent to deallocated instance
后,我Google搜索,但无法获得健康的响应。如果有人遇到这种情况,那么请帮助解决这个问题。下面是我的代码。应用程序崩溃在tableview的reloadData方法
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView{
return 2;
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
if(section==0)
return [[dbSingleton sharedInstance] get_players_count];
else if(section==1)
return 0;
}
- (NSString)tableView:(UITableView)tableView titleForHeaderInSection:(NSInteger)section{
if(section==0)
return @"Player Detail";
return nil;
}
- (UITableViewCellEditingStyle)tableView:(UITableView)tableView editingStyleForRowAtIndexPath:(NSIndexPath)indexPath{
if(indexPath.section==1)
return UITableViewCellEditingStyleNone;
else
return UITableViewCellEditingStyleDelete;
}
}
-(CGFloat)tableView:(UITableView)tableView heightForRowAtIndexPath:(NSIndexPath)indexPath{
return 44;
}
寻找答复。提前致谢。
最后,我找到了解决办法。我做错了的是,我正在调用方法reloadData
上的commitEditingStyle
,它的平均重新加载数据之前删除行,如在回答This Thread中所述。我希望这也能帮助其他人。 感谢您的参与。
[tableView Reload]产生崩溃,那么它肯定会在数据源中出现问题,所以我认为在tableview部分添加断点并检查是否正确更新数据源,否则显示完整的崩溃消息。
@答复,感谢您的回答,但我发现解决方案善意研究我的答案。 – josh 2014-10-28 08:07:22
您是否正在更新数据源? – jsetting32 2014-10-27 13:18:16
请发布完整的堆栈跟踪。 – 2014-10-27 13:29:05
我会说当你通过你的tableView委托方法删除行时[[dbSingleton sharedInstance] get_players_count]没有被更新。 – miya 2014-10-27 13:51:33