【问题标题】:UIPopOverPresentationController crashes on presentationTransitionWillBeginUIPopOverPresentationController 在presentationTransitionWillBegin 上崩溃
【发布时间】:2020-07-06 17:49:43
【问题描述】:

我收到这样的来自 Apple 的崩溃:

崩溃报告太糟糕了,正如 Xcode 所预期的那样,我不得不猜测它来自我的代码的哪里。

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

 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 上崩溃了,但我进行了测试并且工作正常。

【问题讨论】:

    标签: ios swift xcode crash uipopovercontroller


    【解决方案1】:

    您应该同时定义popoverPresentationControllersourceRectsourceView

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2014-11-19
      • 1970-01-01
      • 1970-01-01
      • 2011-05-10
      • 2018-11-01
      • 1970-01-01
      • 1970-01-01
      • 2011-07-24
      相关资源
      最近更新 更多