为什么UIApplication.shared.canOpenURL(:)
方法在iOS 11.4-iPad设备上不起作用?虽然可以在iOS 11和12.0 [iPhone设备]上正常工作!
注意:
https
答案 0 :(得分:0)
好,兄弟,我在使用Facebook开放共享链接时遇到了同样的问题,当我将 shareDialog.mode 更改为 .automatic
时,我解决了该问题所以您可以尝试这种方式并告诉我是否可行?
let url = URL(string: "www.google.com")
let content = LinkShareContent(url: url, quote: "Google")
let shareDialog = ShareDialog(content: content)
shareDialog.mode = .automatic
shareDialog.presentingViewController = self
shareDialog.failsOnInvalidData = true
shareDialog.completion = { result in
}
do {
try shareDialog.show()
} catch {
print("Error")
}
作为我们的讨论,您需要在应用中打开网络视图
因此您可以添加
import UIKit
class WebVC: UIViewController {
@IBOutlet weak var webView: UIWebView!
var url = ""
var firstLoad = true
override func viewDidLoad() {
super.viewDidLoad()
self.setup()
}
func setup() {
self.webView.backgroundColor = Color.white.value
self.webView.delegate = self
var urlRequest = URLRequest(url: URL(string: url)!)
urlRequest.cachePolicy = .reloadIgnoringCacheData
self.webView.loadRequest(urlRequest)
}
}
在您的控制器中,您可以使用
func openWebView() {
let webVC = WebVC()
webVC.url = "www.google.com"
webVC.title = "Google"
self.navigationController?.pushViewController(webVC, animated: true)
}