2016-11-08 47 views
1

我创建了一个按钮,在FacebookSLComposeViewController共享状态。 如何检查用户是否确实点击分享了状态?如何检测用户与SLComposeViewController成功共享

我的如下代码:

@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) 
    } 
} 

回答

1

问题解决了TQ

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

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