url地址为 weixin://dl/business 需要通过浏览器打开跳转到微信
一开始使用safari打开链接 报url异常
func showSafariVC(for url: String){
guard let url = URL(string: url) else {
return
}
let safariVC = SFSafariViewController(url: url)
self.present(safariVC, animated: true, completion: nil)
}
“The Seecified URL has an unsupported scheme.Only HTTP and HTTPS URLs are supported.”
解决方案: 应使用 UIApplication.shared.open方法打开链接
guard let url = URL(string:s ?? "") else {
return
}
if #available(iOS 10,*) {
UIApplication.shared.open(url, options: [:], completionHandler: nil)
} else {
UIApplication.shared.openURL(url)
}
好文阅读
发表评论