这是我与UIActivityVieController共享Google地图链接的代码:
if let myWebsite = NSURL(string: "http://maps.google.com/?q=<\(myLatitude)>,<\(myLongitude)>") {
let objectsToShare = [alertMessage, myWebsite]
let activityVC = UIActivityViewController(activityItems: objectsToShare, applicationActivities: nil)
//New Excluded Activities Code
activityVC.excludedActivityTypes = [UIActivityTypeAirDrop, UIActivityTypeAddToReadingList]
self.presentViewController(activityVC, animated: true, completion: nil)
}
此链接无效;不调用if语句。我该如何解决这个问题?
答案 0 :(得分:1)
您的NSURL的格式应如下所示:
let myWebsite = NSURL(string: "http://maps.google.com/?q=\(myLatitude),\(myLongitude)")
要在字符串中使用字符串,您应该编写
"My string \(otherString)";