UIPopOverPresentationController 在 presentationTransitionWillBegin 上崩溃

UIPopOverPresentationController crashes on presentationTransitionWillBegin

我从 Apple 收到这样的崩溃:

崩溃报告非常糟糕,正如 Xcode 所预期的那样,我不得不猜测它来自我的代码中的何处。

崩溃谈论弹出窗口。当我在显示文档文件夹中的文件的 table 视图上执行这些“删除”和“共享”拖尾滑动操作时,我的代码中唯一有弹出窗口的部分就是“共享”内容。

 override func tableView(_ tableView: UITableView, trailingSwipeActionsConfigurationForRowAt indexPath: IndexPath) -> UISwipeActionsConfiguration? {

    let delete = ... bla bla bla

    let share = UIContextualAction(style: .normal, title: "") {[weak self] (contextualAction, view, boolValue) in
      let oneFile = self?.files![indexPath.section]![indexPath.row]
      
      let activityViewController = UIActivityViewController(
        activityItems: ["Check out these files.", (oneFile?.url)! as URL],
        applicationActivities: nil
      )
      
      activityViewController.popoverPresentationController?.sourceView = self?.view
      self?.present(activityViewController, animated: true, completion: {[weak self] in
        self?.tableView.setEditing(false, animated: true)
      })
    }

    let swipeActions = UISwipeActionsConfiguration(actions: [delete,share])
    swipeActions.performsFirstActionWithFullSwipe = true
    
    return swipeActions
}

你们看到这里有什么可能导致崩溃的吗?

报告显示这在 iPad 上崩溃,但我测试它工作正常。

您应该同时定义 popoverPresentationControllersourceRectsourceView