ios - UIPopOverPresentationController 在presentationTransitionWillBegin 上崩溃

标签 ios swift xcode crash uipopovercontroller

我收到来自 Apple 的崩溃,如下所示:

enter image description here

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

崩溃涉及弹出窗口。我的代码中唯一有弹出窗口的部分是“共享”内容,当我在显示文档文件夹中的文件的表格 View 上执行这些“删除”和“共享”尾随滑动操作时。

 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

关于ios - UIPopOverPresentationController 在presentationTransitionWillBegin 上崩溃,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/62761669/

相关文章:

ios - TableView Swift 中的多项选择

ios - Swift Xcode NSURLConnection.sendSynchronousRequest 已弃用

ios - UIAccelleration值范围

ios - 之间具有透明距离的 Tableview 单元格

ios - QLPreviewController自定义导航栏标题颜色?

ios - VoiceOver 发音问题 : "Live" "ADD"

swift - 分配在 SKAudioNode 上运行 play() 时返回的 SKAction?

ios - CGPoint 编译器错误

ios - 在 Xcode 中复制文件夹内容

ios - 嵌入在根框架中的签名子框架不起作用(Xcode 11.2.1)