简体   繁体   English

某些网站未在 Swift Xcode 9.2 中加载

[英]Some Websites are not loading in Swift Xcode 9.2

Hey :) I am new to swift and I want to create a WebView App.嘿 :) 我是 swift 的新手,我想创建一个 WebView 应用程序。 If I set URL to https://www.apple.com it works perfect.如果我将 URL 设置为https://www.apple.com,它就完美无缺。 But if I change the URl to https://www.berkearas.de it does not work anymore.但是,如果我将 URl 更改为https://www.berkearas.de,它将不再起作用。 The Website is still working and online, and I have a SSL Certificate too.该网站仍在运行并在线,我也有 SSL 证书。 What can I do?我能做什么? Thank you all :)谢谢你们 :)

import WebKit
class ViewController: UIViewController, WKUIDelegate {

    var webView: WKWebView!

    override func loadView() {
        let webConfiguration = WKWebViewConfiguration()
        webView = WKWebView(frame: .zero, configuration: webConfiguration)
        webView.uiDelegate = self
        view = webView
    }
    override func viewDidLoad() {
        super.viewDidLoad()

        let myURL = URL(string:"https://www.berkearas.de")
        let myRequest = URLRequest(url: myURL!)
        webView.load(myRequest)
    }}

Just add NSAppTransportSecurity key into your .plist file then everything working fine.只需将NSAppTransportSecurity密钥添加到您的 .plist 文件中,然后一切正常。

<key>NSAppTransportSecurity</key>  
 <dict>  
      <key>NSAllowsArbitraryLoads</key><true/>  
 </dict>

截屏

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 单元测试未编译 - Swift Xcode 9.2 - Unit tests not compiling - Swift Xcode 9.2 Xcode 9.2被困在编译Swift 3.2项目中 - Xcode 9.2 stuck in compiling Swift 3.2 Project 迅速; xcode 9.2-通过TabBar和导航控制器传递参数 - swift; xcode 9.2 - Passing arguments over TabBar & navigation controller 如何将私有框架导入Xcode 9.2(iOS 11),迅速 - How To Import Private Frameworks to Xcode 9.2 (iOS 11) , swift MapKit(Swift 4)Xcode 9.2 - &#39;无法插入第4角的法律归属&#39; - MapKit (Swift 4) Xcode 9.2 - 'Could not inset legal attribution from corner 4' 根据单元格中的内容自动更改单元格内容-Xcode 9.2 Swift 4 - Automatically change cell content based on content in cell - Xcode 9.2 Swift 4 为什么应用归档在 iOS、swift、xcode 9.2 中使用自定义框架失败 - Why app archive failed with custom frameworks in iOS, swift, xcode 9.2 在Xcode Swift上保存和加载整数 - Saving And Loading An Integer On Xcode Swift 我的启动屏幕有时保持黑屏和空白(iOS 9.2,Swift 2,Xcode 7.2) - My splash screen sometimes remains black and blank (iOS 9.2, swift 2, Xcode 7.2) 接收的json数据格式为531字节,在swift 4.1和Xcode 9.2中给出了curruptedData错误 - Received json data is in form of 531 bytes and giving curruptedData error in swift 4.1 and Xcode 9.2
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM