[英]iOS Facebook share video Swift
我正在寻找一种在Facebook上分享我的应用程序视频的方法。 我将SDK安装到了Facebook,并按照说明进行操作,但是我不明白为什么我不能分享我的视频。
let fbVideo:FBSDKShareVideo = FBSDKShareVideo()
fbVideo.videoURL = url
let content: FBSDKShareVideoContent = FBSDKShareVideoContent()
content.video = fbVideo
FBSDKShareDialog.showFromViewController(self, withContent: content, delegate: self)
我有一个参数委托错误:
Cannot convert value of type 'ShareViewController' to expected argument type 'FBSDKSharingDelegate!'
请注意,我在我的类ShareViewController中。
有没有其他方法可以在Facebook上分享视频? 谢谢
方法showFromViewController:withContent:delegate:
期望委托参数的类型为FBSDKSharingDelegate
。 您提供的是ShareViewController
类型的值, ShareViewController
不是FBSDKSharingDelegate
,这意味着所述视图控制器不符合该类型。 您需要使您的视图控制器符合FBSDKSharingDelegate
类型。 举个例子:
class ShareViewController: UIViewController, FBSDKSharingDelegate {
// code
}
或传入另一个符合FBSDKSharingDelegate
类型的FBSDKSharingDelegate
。
您必须实现FBSDKSharingDelegate
协议及其方法。
class ViewController: UIViewController ,FBSDKSharingDelegate{
//add following methods to the class:
func sharer(_ sharer: FBSDKSharing!, didCompleteWithResults results: [AnyHashable : Any]!) {
print("Completed");
}
func sharer(_ sharer: FBSDKSharing!, didFailWithError error: Error!) {
print("Failed with error : \(error.localizedDescription)");
}
func sharerDidCancel(_ sharer: FBSDKSharing!) {
print("Cancelled")
}
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.