@IBAction func download(_ sender: Any) {
if let url = URL(string: "\(imgURL)") {
UIApplication.shared.openURL(url as URL)
}
print(imgURL)
}
如果我按下按钮,网址就不会打开。 consol说正确的网址:https://scontent-ams3-1.cdninstagram.com/t51.2885-19/18514045_212505245924563_1350282415863496704_a.jpg但网址不会打开。请帮忙!感谢
let urlstr = "\(profile_pic_url_hd)"
if var comps = URLComponents(string: urlstr) {
var path = comps.path
var pathComps = path.components(separatedBy: "/")
pathComps.remove(at: 2) // this removes the s320x320
path = pathComps.joined(separator: "/")
comps.path = path
if let newStr = comps.string {
print(newStr)
self.imgURL = "\(newStr)"
}
}