gpt4 book ai didi

ios - UIActivityController 共享 URL 文件

转载 作者:可可西里 更新时间:2023-10-31 23:57:49 25 4
gpt4 key购买 nike

我想分享在应用程序中创建的 URL 文件和文本。但它似乎只能共享文本,不能共享 URL 或 UIImage 等任何数据。我使用的代码:

let sharedVideo = Video(Title: _data[1], VideoID: _data[0], Duration: _data[3], ViewCount: _data[2])
let sharedURL = VideoManager.exportData(video: sharedVideo)
let shareItems:Array = [sharedURL,"check this out baby!"] as [Any]

let activityViewController = UIActivityViewController(activityItems: shareItems, applicationActivities: nil)

self.present(activityViewController, animated: true, completion: nil)

我还使用 UIImage 对象而不是 sharedURL 来查看 URL 是否有问题。

即使是图像文件也不起作用。当我单击 UIActivityViewController 中的共享按钮时,它仅适用于文本,没有 URL 或图像。我在 Xcode 8 中使用 Swift 3

谢谢。

PS:我确信 sharedURL 对象不是 nil 也不是未定义的。

最佳答案

试试这个:

 @IBAction func btnExport(sender: AnyObject)
{

let someText:String = "Hello want to share text also"
let objectsToShare:URL = URL(string: "http://www.google.com")!
let sharedObjects:[AnyObject] = [objectsToShare as AnyObject,someText as AnyObject]
let activityViewController = UIActivityViewController(activityItems : sharedObjects, applicationActivities: nil)
activityViewController.popoverPresentationController?.sourceView = self.view

activityViewController.excludedActivityTypes = [ UIActivityType.airDrop, UIActivityType.postToFacebook,UIActivityType.postToTwitter,UIActivityType.mail]

self.present(activityViewController, animated: true, completion: nil)

}

关于ios - UIActivityController 共享 URL 文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40191377/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com