https
リクエストを使用して、UIWebView
の読み込みに問題があります。 私はいくつかの関連する答えを読んだが、彼らは私をさらに混乱させた。 ここに私のコードです: リンク、私は別のページにリダイレクトされます使用しています。はUIWebViewでhttpsを読み込めません
func webView(webView: UIWebView, shouldStartLoadWithRequest request: NSURLRequest, navigationType: UIWebViewNavigationType) -> Bool {
let urlConnection: NSURLConnection = NSURLConnection(request: request as URLRequest, delegate: self)!
urlConnection.start()
return true
}
func connection(_ connection: NSURLConnection, canAuthenticateAgainstProtectionSpace protectionSpace: URLProtectionSpace) -> Bool {
return true
}
func connection(_ connection: NSURLConnection, didReceive challenge: URLAuthenticationChallenge) {
let host = "www.ad.admitad.com"
if challenge.protectionSpace.authenticationMethod == NSURLAuthenticationMethodServerTrust &&
challenge.protectionSpace.host == host {
let credential = URLCredential(trust: challenge.protectionSpace.serverTrust!)
challenge.sender!.use(credential, for: challenge)
} else {
challenge.sender!.performDefaultHandling!(for: challenge)
}
}
次のように私はこれらのプロトコル
NSURLConnectionDelegate
に準拠しようとしたこの答え
UIWebView to view self signed websites (No private api, not NSURLConnection) - is it possible?
の助けを借りてhttp
にhttps
を変更すると、細かいロードUIWebViewDelegate
さ
class PartnersWebViewControlerViewController: UIViewController, NSURLConnectionDelegate, UIWebViewDelegate {
@IBOutlet weak var admitadWebView: UIWebView!
let url = "https://ad.admitad.com/g/54tjzvqfv92260a476c4ffa09d8e84/subid/26/"
override func viewDidLoad() {
super.viewDidLoad()
admitadWebView.delegate = self
let requestURL = URL(string:url)
let request = URLRequest(url: requestURL!)
admitadWebView.loadRequest(request)
}
}
しかし、まだ私は白い画面があり、何もログに記録しません。
ご協力いただきありがとうございます。私がそのような問題に立ち寄ったのは初めてのことです。
私は、IOS 10.3 UPDを使用しています:この問題は、(iphone 6)
ステータスはすでに変更されていますが、http:// – dand1
ではなく、httpsで問題が発生しています。あなたのアプリにロードされていない場合は、URLに問題はありません。あなたは何か他のことを間違えたかもしれません。 – ChanWarde
ああ、はい、私はシミュレータで起動しようとし、それは働いた。しかし、問題は私のデバイスに残ります – dand1