0

我尝试将照片库中选定视频中的视频分享到 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
     }
4

1 回答 1

0

当我将“UIImagePickerControllerReferenceURL”更改为“UIImagePickerControllerMediaURL”时,它完全有效

 func imagePickerController(_ picker: UIImagePickerController, didFinishPickingMediaWithInfo info: [UIImagePickerController.InfoKey : Any]) {
        self.dismiss(animated: true, completion: nil)
        videoURL = info[UIImagePickerController.InfoKey.init(rawValue: "UIImagePickerControllerMediaURL")] as? URL
 }
于 2020-10-04T23:50:44.300 回答