ios - 应用程序在 tableview 的 reloadData 方法上崩溃

标签 ios objective-c uitableview

我的应用程序在调用 [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/

相关文章:

ios - 在类实例变量之前声明时出现 NS_ENUM 错误

ios - Apple-Mach-O 链接器错误 UIKit iOS 8

objective-c - 支持多语言的 objc 语法高亮库?

ios - Swift 将 TableView 分成两部分

ios - 如何在滚动时折叠 UITableView header

iphone - cell.detailTextLabel.text 不起作用...为什么

ios - 如何从初始 View 屏幕或特定 View 隐藏导航栏?

ios - 为什么 UITableView 呈现额外的行(多于数据数组中的行)?

objective-c - iOS - 如何使用无序的 CGPoints 绘制特定的 CGPath

ios - 委托(delegate)有问题,我的委托(delegate)总是零,tvOS,swift 2.0