我想分享一个到社交应用程序的URL方案链接,这样当用户在safari上打开社交页面时,当他们点击链接时,URL方案将调用我设置的应用程序。但是当我分享时,它只分享文本。如何共享链接而不是文本。
以下是代码:
@IBAction func shareButtonAction(sender: AnyObject) {
print("share")
let myShare = "TestSafari://"
let shareVC: UIActivityViewController = UIActivityViewController(activityItems: [myShare], applicationActivities: nil)
self.presentViewController(shareVC, animated: true, completion: nil)
}
答案 0 :(得分:0)
您可能需要先按照特定顺序放置文本,然后放置网址。试试这个:
let string: String = ...
let URL: NSURL = ...
let shareVC = UIActivityViewController(activityItems: [string, URL])
答案 1 :(得分:0)
let activityViewController = UIActivityViewController(
activityItems: [image],
applicationActivities: nil)
activityViewController.excludedActivityTypes = [UIActivityTypeMessage,UIActivityTypeMail,UIActivityTypeCopyToPasteboard,UIActivityTypeAirDrop];
presentViewController(activityViewController, animated: true, completion: nil)
将此代码用于Present ActivityViewController,只将activityItems更改为您的字符串。