ios - 如何在 Swift 中创建类似 Android 上的共享选项
解决方案
尝试这样的事情:
private func shareWhatYouWant() {
//pop invite view
var textToShare = "Your message"
if let myWebsite = NSURL(string: "Yourwebsite.com") {
let objectsToShare = [textToShare, myWebsite] as [Any]
let activityVC = UIActivityViewController(activityItems: objectsToShare, applicationActivities: nil)
//New Excluded Activities Code
activityVC.completionWithItemsHandler = {
activity, sucess, items, error in
if !sucess {
print("cancelled")
return
}
if activity == UIActivityType.postToFacebook {
print("share on facebook")
}
if activity == UIActivityType.postToTwitter {
print("share on twitter")
}
if activity == UIActivityType.message {
print("share on message")
}
if activity == UIActivityType.addToReadingList {
print("air drop select")
}
}
activityVC.popoverPresentationController?.sourceView = sender as? UIView
self.present(activityVC, animated: true, completion: nil)
}
}
推荐阅读
- python-2.7 - Selenium 清除输入字段的不同行为
- angular - Angular 9 通用和延迟加载的路由
- php - 如何从 Swift JSONEncoder 向 PHP 文件发送 POST 请求
- javascript - Reactjs - setState 在 fetch 中的更好解决方案
- javascript - Fetch 不返回任何东西
- python - 如何在 Python 的 Dash 包中创建两个可以修改卡片体的按钮,每个按钮都有自己的方式?
- c# - 类型推断的问题
- javascript - JavaScript 中的所有数据类型都是可枚举的吗?
- kubernetes-helm - 我们可以为掌舵图的 values.yaml 中的键设置 2 个 doubleqoutes 值吗?
- sql - 参数类型的函数 STRING 没有匹配的签名:INT64。支持的签名:STRING(TIMESTAMP, [STRING]) at [28:10]