有没有办法创建一个下面有描述的 url vCard 并使用 swift 4 共享它?... iOS 地图是否共享标记的位置
Is there a way to create a url vCard with a description below it and share it using swift 4?... iOS Maps do it sharing a marked location
我正在尝试像这样通过 vCard 共享位置:
var vCardString = [
"BEGIN:VCARD",
"VERSION:4.0",
"N:;Shared Location;;;",
"FN:Shared Location",
"item1.URL:http://maps.apple.com/?ll=\(coordinate.latitude),\(coordinate.longitude)",
"item1.X-ABLabel:map url",
"END:VCARD"
].joined(separator: "\n")
let myData = vCardString.data(using: .utf8)! as NSData
var items = [Any]()
let vCardActivity = NSItemProvider(item: myData!, typeIdentifier: kUTTypeVCard as String)
items.append(vCardActivity)
let activityViewController = UIActivityViewController(activityItems: items, applicationActivities: nil)
present(activityViewController, animated:true, completion: nil)
这确实有效,但我无法在 vCard 下方添加描述...
I have this
I'm looking for this
我试过添加另一个项目:
var items = [Any]()
let vCardActivity = NSItemProvider(item: myData!, typeIdentifier: kUTTypeVCard as String)
items.append(vCardActivity)
let myTitle = "This is my title"
items.append(myTitle)
let activityViewController = UIActivityViewController(activityItems: items, applicationActivities: nil)
present(activityViewController, animated:true, completion: nil)
但它只显示 vCard
非常感谢
如果在 VCard 中添加地址字段会怎样?
像这样:
let vCardString = [
"BEGIN:VCARD",
"VERSION:4.0",
"N:;Shared Location;;;",
"FN:Shared Location",
"ADR;TYPE=HOME;LABEL=42 Plantation St. Baytown, LA 30314 United States of America:;;42 Plantation St.;Baytown;LA;30314;United States of America",
"item1.URL:http://maps.apple.com/?ll=25.686613,-100.316116",
"item1.X-ABLabel:map url",
"END:VCARD"
].joined(separator: "\n")
你会得到这样的东西:
我正在尝试像这样通过 vCard 共享位置:
var vCardString = [
"BEGIN:VCARD",
"VERSION:4.0",
"N:;Shared Location;;;",
"FN:Shared Location",
"item1.URL:http://maps.apple.com/?ll=\(coordinate.latitude),\(coordinate.longitude)",
"item1.X-ABLabel:map url",
"END:VCARD"
].joined(separator: "\n")
let myData = vCardString.data(using: .utf8)! as NSData
var items = [Any]()
let vCardActivity = NSItemProvider(item: myData!, typeIdentifier: kUTTypeVCard as String)
items.append(vCardActivity)
let activityViewController = UIActivityViewController(activityItems: items, applicationActivities: nil)
present(activityViewController, animated:true, completion: nil)
这确实有效,但我无法在 vCard 下方添加描述...
I have this
I'm looking for this
我试过添加另一个项目:
var items = [Any]()
let vCardActivity = NSItemProvider(item: myData!, typeIdentifier: kUTTypeVCard as String)
items.append(vCardActivity)
let myTitle = "This is my title"
items.append(myTitle)
let activityViewController = UIActivityViewController(activityItems: items, applicationActivities: nil)
present(activityViewController, animated:true, completion: nil)
但它只显示 vCard
非常感谢
如果在 VCard 中添加地址字段会怎样?
像这样:
let vCardString = [
"BEGIN:VCARD",
"VERSION:4.0",
"N:;Shared Location;;;",
"FN:Shared Location",
"ADR;TYPE=HOME;LABEL=42 Plantation St. Baytown, LA 30314 United States of America:;;42 Plantation St.;Baytown;LA;30314;United States of America",
"item1.URL:http://maps.apple.com/?ll=25.686613,-100.316116",
"item1.X-ABLabel:map url",
"END:VCARD"
].joined(separator: "\n")
你会得到这样的东西: