【问题标题】:Not able to tweet video through twitter using UIActivityViewController in iOS无法在 iOS 中使用 UIActivityViewController 通过 Twitter 发布视频
【发布时间】:2019-12-16 23:26:53
【问题描述】:

无法通过 UIActivityViewController 在 Twitter 上分享视频。

文本和本地视频存储工作正常。所以身份验证不是问题。

如果视频存储在应用程序本身中,则共享工作正常 路径网址

file:///private/var/containers/Bundle/Application/B7855569-3254-4CC2-9573-254D09528E38/podhunt.app/PlugIns/podhunt-shareExtension.appex/demo_video.mp4

如果路径在下方,则推特分享不起作用 路径网址

file:///var/mobile/Containers/Data/PluginKitPlugin/5831780C-50AF-41FA-8435-941CAC47EBE6/Documents/10c41d4a-c161-4c78-bc61-ca789804a982.mp4

这不起作用

    URLSession.shared.downloadTask(with: audioUrl) { location, response, error in
    guard let location = location, error == nil else { return }
    do {
           try FileManager.default.moveItem(at: location, to: destinationUrl)
           DispatchQueue.main.async {
               let activityVC = UIActivityViewController(activityItems: [destinationUrl], applicationActivities: nil)
               self.present(activityVC, animated: true, completion: nil)
             }
           } catch {
      }
    }.resume()

这行得通


URLSession.shared.downloadTask(with: audioUrl) { location, response, error in
    guard let location = location, error == nil else { return }
    do {
           try FileManager.default.moveItem(at: location, to: destinationUrl)
           DispatchQueue.main.async {
           guard let path = Bundle.main.path(forResource: "demo_video", ofType:"mp4") else {
               return
            }
               let activityVC = UIActivityViewController(activityItems: [URL(fileURLWithPath: path)],applicationActivities: nil)
               self.present(activityVC, animated: true, completion: nil)
             }
           } catch {
      }
    }.resume() 

我正在开发 iOS 应用扩展。

【问题讨论】:

    标签: ios swift twitter


    【解决方案1】:

    已解决。显然,我正在将 mp3 文件作为 mp4 共享给它无法识别的 twitter。您不能将 mp3 文件分享到 twitter,因为它不支持音频格式。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2017-02-08
      • 1970-01-01
      • 2021-06-15
      • 2015-12-30
      • 2015-08-17
      • 2016-07-14
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多