我的应用程序在调用 [tableView reloadData]
TableView 的方法后崩溃。这是在删除一行 TableView (具有 TableView 默认删除行为)并调用 [tableView reloadData]
之后发生的,然后在此委托(delegate) numberOfSectionsInTableView
应用程序崩溃之后显示崩溃消息 [UITableViewCell _setDeleteAnimationInProgress : ] : message sent to deallocated instance
,我用谷歌搜索但无法获得正常响应。如果有人遇到这种崩溃,请帮助找出这个问题。下面是我的代码。
- (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;
}
正在寻找回应。提前致谢。
最佳答案
最后,我找到了解决方案。我做错的是我在 commitEditingStyle
上调用方法 reloadData
,这意味着在删除行之前重新加载数据,如 This Thread 的回答中所述.我希望这也会对其他人有所帮助。
感谢您的参与。
关于ios - 应用程序在 tableview 的 reloadData 方法上崩溃,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26588419/