我正在尝试将自定义活动添加到我的 UIDocumentBrowserController 长按菜单 - UIActivityViewController。选中后,默认共享活动会很好地指向用户刚刚长按的文件图标。
如何获取 sourceRect 以便我的活动可以以类似的方式呈现?
let shareBundle = UIDocumentBrowserAction(identifier:
"com.mycompany.myapp.shareBundle", localizedTitle: "Share with Data",
availability: [.menu], handler: { urls in
if urls.count > 0 {
let objectsToShare: [URL] = [urls]
let activityVC = UIActivityViewController(activityItems: objectsToShare, applicationActivities: nil)
activityVC.popoverPresentationController?.sourceView = self.view
activityVC.popoverPresentationController?.sourceRect = // That's the problem!
self.present(activityVC, animated: true, completion: nil)
}
})