iOS Facebook分享视频Swift

问题描述 投票:0回答:2

我正在寻找一种在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上分享视频?谢谢

ios swift facebook facebook-graph-api facebook-sdk-4.0
2个回答
1
投票

方法showFromViewController:withContent:delegate:期望委托参数为FBSDKSharingDelegate类型。您提供的类型为ShareViewController而不是FBSDKSharingDelegate,这意味着所述视图控制器不符合该类型。您需要使视图控制器符合类型FBSDKSharingDelegate。举个例子:

class ShareViewController: UIViewController, FBSDKSharingDelegate {
    // code
}

或传入另一个符合FBSDKSharingDelegate类型的对象。


0
投票

你必须实现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")
        }

    }
© www.soinside.com 2019 - 2024. All rights reserved.