【发布时间】:2017-06-29 01:02:37
【问题描述】:
抱歉,这是我的第一个 iOS 应用!我正在尝试使用 QRCodeReader.swift 为应用程序实现一个非常简单的 QR 码扫描器,但我不知道如何处理结果中的 URL。它应该立即重定向到链接,但不起作用。谢谢!
func reader(_ reader: QRCodeReaderViewController, didScanResult result: QRCodeReaderResult) {
reader.stopScanning()
dismiss(animated: true) { [weak self] in
let url = URL(string: result.value)!
if #available(iOS 10.0, *) {
UIApplication.shared.open(url, options: [:], completionHandler: nil)
} else {
UIApplication.shared.openURL(url)
}
}
}
【问题讨论】:
-
你打开系统设置有没有发现这个问题?
-
还没有!它会扫描二维码,但不会转到链接。
-
那么这个链接是什么?因为我使用了你的代码并且它有效。
-
应该用任意url打开默认浏览器
标签: ios swift xcode cocoa swift3