我在应用程序中创建了一个按钮,使用SLComposeViewController在Facebook上共享状态。 如何检查用户是否确实单击共享状态?

我的代码如下:

@IBAction func fbBtn(_ sender: Any) {

    if SLComposeViewController.isAvailable(forServiceType: SLServiceTypeFacebook) {
        let fbShare:SLComposeViewController = SLComposeViewController(forServiceType: SLServiceTypeFacebook)

        self.present(fbShare, animated: true, completion: nil)

    } else {
        let alert = UIAlertController(title: "Accounts", message: "Please login to a Facebook account to share.", preferredStyle: UIAlertControllerStyle.alert)

        alert.addAction(UIAlertAction(title: "OK", style: UIAlertActionStyle.default, handler: nil))
        self.present(alert, animated: true, completion: nil)
    }
}

最佳答案

问题解决的TQ

fbShare.completionHandler = { (result:SLComposeViewControllerResult) -> Void in
            switch result {
            case SLComposeViewControllerResult.cancelled:
                print("Cancelled")
                break

            case SLComposeViewControllerResult.done:
                print("Done")
                break
            }
        }

10-04 11:34