0

我正在使用共享表打开一些本机应用程序 - 即邮件、提醒、便笺、消息。以下是我在单击共享按钮后打开共享表的代码。

我正在寻找一种方法来识别用户单击共享表,即当用户在共享表上选择一个选项时调用的 API。我搜索并找不到任何东西,所以不确定是否有办法识别用户选择?

func presentShareSheet(content: String, subject: String = "", shareButton: UIView? = nil, presentingVC: UIViewController? = nil) -> Guarantee<Void> {
    return Guarantee { seal in

        let itemsToShare: [Any] = [someItems]
        let activityViewController = UIActivityViewController(activityItems: itemsToShare, applicationActivities: nil)
 
        activityViewController.popoverPresentationController?.sourceView = shareButton
        activityViewController.completionWithItemsHandler = { activityType, completed, items, error in
            // update color of navigation bar
            seal(())
        }
        
        if let vc = presentingVC ?? UIApplication.shared.topMostViewController() {
            vc.present(activityViewController, animated: true)
        } else {
            seal(())
        }
    }
}
4

0 回答 0