【发布时间】:2019-02-28 06:20:48
【问题描述】:
我们已经为我们的应用实现了滑动删除功能,但不知何故,我们在 Crashlytics 上看到了这种间歇性的 prod 崩溃。
我一直在关注有关此崩溃的几篇 StackOverflow 帖子,但我无法获得此崩溃的确切原因。
我已尝试多次产生此崩溃,但每次都正常。
任何想法或想法,如果我在这里做错了什么?下面是崩溃报告和当前运行的代码 sn-p。
@available(iOS 11.0, *)
private func actionForType(alertID: String, swipeAction: AlertSwipeActionType, indexPath: IndexPath) -> UIContextualAction {
let contexualAction = UIContextualAction(style: .normal, title: nil) { [weak self] (action, view, completion) in
guard let strongSelf = self else {
return
}
switch swipeAction {
......
case .affirm:
completion(true)
strongSelf.dispositionAlert(id: alertID, status: true, indexPath: indexPath)
......
}
}
......
return contexualAction
}
fileprivate func dispositionAlert(id: String, status: Bool, indexPath: IndexPath) {
let dispositionRequest = AlertDispositionUpdateBody(id: id, disposition: status, questionId: nil)
self.updateAlertDispositionStatus(request: dispositionRequest) { [weak self] in
guard let strongSelf = self else {
return
}
strongSelf.removeCellWithAnimationAt(indexPath: indexPath)
strongSelf.loadAlerts()
}
}
fileprivate func removeCellWithAnimationAt(indexPath: IndexPath) {
DispatchQueue.main.async {
self.tableView.beginUpdates() // likely not required
self.removeAlertAtIndexPath(indexPath)
self.tableView.deleteRows(at: [indexPath], with: .fade)
self.tableView.endUpdates() // likely not required either
}
}
@objc func loadAlerts() {
self.startLoadingAnimation()
self.alertsFooterList.removeAll()
AlertsManager.sharedInstance.loadMemberAlerts()
}
fileprivate func removeAlertAtIndexPath(_ indexPath: IndexPath) {
let alertStatus = self.alertTabType.statusToLoad[indexPath.section]
if let alerts = self.alertsList[alertStatus],
alerts.count > indexPath.row {
self.alertsList[alertStatus]?.remove(at: indexPath.row)
}
}
【问题讨论】:
-
您确定在调用
removeCellWithAnimationAt方法之前,您的表格单元格已加载吗?还是单元格已被删除,并且此方法被调用了两次? -
崩溃分析给出行号和功能你能分享这些细节吗?
标签: ios swift uitableview swift4.2