ios - 格式化分享的信息share sheet
ios - format the information shared with share sheet
我正在使用以下代码进行分享 sheet:
let url = "https://somelink.com"
let image = "https://myserver/an_image.png"
let text = "Join now!"
let shareSheetVC = UIActivityViewController(activityItems: [image, url, text], applicationActivities: nil)
shareSheetVC.popoverPresentationController?.sourceView = sender
shareSheetVC.popoverPresentationController?.sourceRect = sender.frame
present(shareSheetVC, animated: true)
我想要的是这样的:
然而,当我分享时,我得到
https://somelink.com
https:///myserver/an_image.png
立即加入!
我如何格式化它来完成类似示例的操作?
这是使用 UIActivityViewController
分享 Text
、Image
和 URL
的基本示例
let text = "Join Now!"
let image = UIImage(named: "your_image")
let myWebsite = URL(string: "https://somelink.com")
let shareAll = [text , image! , myWebsite]
let activityViewController = UIActivityViewController(activityItems: shareAll, applicationActivities: nil)
activityViewController.popoverPresentationController?.sourceView = self.view
activityViewController.popoverPresentationController?.sourceRect = sender.frame
self.present(activityViewController, animated: true, completion: nil)
希望你明白。
或者,您可以从不同的角度解决这个问题,并尝试通过添加以下内容来修复您的网页:
<meta property="og:image" content="https://myserver/an_image.png">
<title>Join now!</title>
这些标签将默认从 UIActivityViewController.
中获取
我正在使用以下代码进行分享 sheet:
let url = "https://somelink.com"
let image = "https://myserver/an_image.png"
let text = "Join now!"
let shareSheetVC = UIActivityViewController(activityItems: [image, url, text], applicationActivities: nil)
shareSheetVC.popoverPresentationController?.sourceView = sender
shareSheetVC.popoverPresentationController?.sourceRect = sender.frame
present(shareSheetVC, animated: true)
我想要的是这样的:
然而,当我分享时,我得到
https://somelink.com https:///myserver/an_image.png 立即加入!
我如何格式化它来完成类似示例的操作?
这是使用 UIActivityViewController
Text
、Image
和 URL
的基本示例
let text = "Join Now!"
let image = UIImage(named: "your_image")
let myWebsite = URL(string: "https://somelink.com")
let shareAll = [text , image! , myWebsite]
let activityViewController = UIActivityViewController(activityItems: shareAll, applicationActivities: nil)
activityViewController.popoverPresentationController?.sourceView = self.view
activityViewController.popoverPresentationController?.sourceRect = sender.frame
self.present(activityViewController, animated: true, completion: nil)
希望你明白。
或者,您可以从不同的角度解决这个问题,并尝试通过添加以下内容来修复您的网页:
<meta property="og:image" content="https://myserver/an_image.png">
<title>Join now!</title>
这些标签将默认从 UIActivityViewController.
中获取