我正在尝试使用SLComposeViewController在iOS应用中与Facebook分享帖子.但是,如果我在帖子上点击取消,则“完成”的结果将返回到完成处理程序而不是“已取消”.当我点击帖子时,它解散并冻结应用程序而不返回任何结果.如果设备上未安装Facebook应用程序,此代码可以正常工作.
这是我用于Facebook部分的代码:
if SLComposeViewController.isAvailableForServiceType(SLServiceTypeFacebook) {
var facebookVC: SLComposeViewController = SLComposeViewController(forServiceType: SLServiceTypeFacebook)
facebookVC.completionHandler = {
(result: SLComposeViewControllerResult) -> Void in
println("result: \(result.rawValue)")
switch(result) {
case SLComposeViewControllerResult.Cancelled:
println("Facebook CANCELLED")
break;
case SLComposeViewControllerResult.Done:
println("Facebook DONE")
self.facebookButton.selected = true
self.facebookButton.userInteractionEnabled = false
break;
default:
break;
}
}
self.presentViewController(facebookVC, animated: true, completion: nil)
} else {
var alert: UIAlertView!
alert = UIAlertView(title: "No Facebook Account", message: "There are no Facebook account configured. You can add or create a Facebook account in Settings", delegate: self, cancelButtonTitle: "OK")
alert.show()
}
最佳答案 我在iOS 8.3上遇到了同样的问题,只有Facebook服务类型.
看起来像Apple在社交框架中的错误.