我尝试将照片库中选定视频中的视频分享到 Instagram 故事
func shareToInstagramStories(video: NSData) {
// NOTE: you need a different custom URL scheme for Stories, instagram-stories, add it to your Info.plist!
guard let instagramUrl = URL(string: "instagram-stories://share") else {
return
}
if UIApplication.shared.canOpenURL(instagramUrl) {
let pasterboardItems = [["com.instagram.sharedSticker.backgroundVideo": video as Any]]
UIPasteboard.general.setItems(pasterboardItems)
UIApplication.shared.open(instagramUrl)
} else {
//fail
}
}
这是我的图像选择器功能
func imagePickerController(_ picker: UIImagePickerController, didFinishPickingMediaWithInfo info: [UIImagePickerController.InfoKey : Any]) {
self.dismiss(animated: true, completion: nil)
videoURL = info[UIImagePickerController.InfoKey.init(rawValue: "UIImagePickerControllerReferenceURL")] as? NSURL
}