无法在 iOS 中使用 UIActivityViewController 通过 Twitter 发布视频 [英] Not able to tweet video through twitter using UIActivityViewController in iOS

查看:32
本文介绍了无法在 iOS 中使用 UIActivityViewController 通过 Twitter 发布视频的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

无法通过 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.mp

这不起作用

 URLSession.shared.downloadTask(with: audioUrl) { location, response, error in守卫让位置=位置,错误==零其他{返回}做 {试试 FileManager.default.moveItem(at: location, to: destinationUrl)DispatchQueue.main.async {让activityVC = UIActivityViewController(activityItems: [destinationUrl], applicationActivities: nil)self.present(activityVC,动画:true,完成:nil)}} 抓住 {}}.恢复()

这有效

<预><代码>URLSession.shared.downloadTask(with: audioUrl) { location, response, error in守卫让位置=位置,错误==零其他{返回}做 {试试 FileManager.default.moveItem(at: location, to: destinationUrl)DispatchQueue.main.async {守卫让路径 = Bundle.main.path(forResource: "demo_video", ofType:"mp4") else {返回}让activityVC = UIActivityViewController(activityItems: [URL(fileURLWithPath: path)],applicationActivities: nil)self.present(activityVC,动画:true,完成:nil)}} 抓住 {}}.恢复()

我正在开发 iOS 应用扩展.

解决方案

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

Not able to share the video on twitter through UIActivityViewController.

Text and local video storage works fine. So authentication is not an issue.

If video is stored in the app itself, then the share works fine Path URL

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

If the path is below, then the twitter share does not work Path Url

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

This does not work

    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()

This works


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() 

I am working on iOS app extension.

解决方案

Resolved. Apparently I was sharing mp3 file as an mp4 to twitter which it does not recognize. You cannot share mp3 file to twitter as it does not support audio format.

这篇关于无法在 iOS 中使用 UIActivityViewController 通过 Twitter 发布视频的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆