我实现了 Twitter Kit SDK 并按照他们的所有说明将视频分享到 Twitter。这是我的代码:
func shareToTwitter(){
var composer : TWTRComposerViewController?
composer = TWTRComposerViewController(initialText: "#metronome", image: nil, videoURL: URL(string: (MainController.sharedInstance.mergedFileClip?.compiledfileURL?.absoluteString)!))
composer?.delegate = self
if (Twitter.sharedInstance().sessionStore.hasLoggedInUsers()) {
// App must have at least one logged-in user to compose a Tweet
present(composer!, animated: true, completion: nil)
} else {
// Log in, and then check again
Twitter.sharedInstance().logIn { session, error in
if session != nil { // Log in succeeded
self.present(composer!, animated: true, completion: nil)
} else {
let alert = UIAlertController(title: "No Twitter Accounts Available", message: "You must log in before presenting a composer.", preferredStyle: .alert)
self.present(alert, animated: false, completion: nil)
}
}
}
}
它成功触发登录并且我能够撰写推文,但是奇怪的是,它共享视频中的图像而不是实际视频。我确信我在参数中传递的 videoURL 是视频 URL,因为我使用相同的 URL 将视频保存到用户相机胶卷。
我可能做错了什么?