→ howdiun:willSendRequestForAuthenticationChallenge may help 04/10 09:48
喔喔 howdiun大大感謝
我剛查了一下
http://goo.gl/JMoaq0
這網頁有人回答是實做這兩個delegate
==============================================================================
- (BOOL)connection:(NSURLConnection *)connection
canAuthenticateAgainstProtectionSpace:(NSURLProtectionSpace *)protectionSpace
{
return [protectionSpace.authenticationMethod
isEqualToString:NSURLAuthenticationMethodServerTrust];
}
- (void)connection:(NSURLConnection *)connection
didReceiveAuthenticationChallenge:(NSURLAuthenticationChallenge *)challenge
{
[challenge.sender useCredential:[NSURLCredential
credentialForTrust:challenge.protectionSpace.serverTrust]
forAuthenticationChallenge:challenge];
[challenge.sender
continueWithoutCredentialForAuthenticationChallenge:challenge];
}
==============================================================================
如果針對用NSURLConnection的 應該我只要把這些拿來用
然後delegate:self 就可以
實測結果 有幫助 :) 一些用NSURLConnection的都正常了
只是對於
http://goo.gl/AJ0DXl
這種直接使用webview的我還是沒有頭緒
webview的class reference 網頁
http://goo.gl/HYoqVq
找不著auth相關的東西>.<
※ 編輯: donkeychen (210.59.147.226), 04/10/2014 10:49:51
※ 編輯: donkeychen (210.59.147.226), 04/10/2014 12:00:50
→ howdiun:用shouldStartLoadWithRequest抓給NSURLConnection讀取 04/10 14:11
→ donkeychen:大大我還沒用 shouldStartLoadWithRequest 04/10 15:52
→ donkeychen:只是光改NSURLConnection後 "有時"就可以了 04/10 15:53
→ donkeychen:早上改完時還不能連 現在又可以 我確認看看^^; 謝謝唷 04/10 15:53
經過多次測試
用 NSURLRequest給WebView loadRequest時
真的是時而出現 時而失敗
(失敗時就是空白畫面 成功就是有顯示)
我找不到shouldStartLoadWithRequest的用法
在下面網址找到一個方式
http://goo.gl/8qz6B2
這邊的解答的地方有註解
Please note: This API is currently unsupported, and should really only be
used in a safe testing environment. For further details, take a look at this
CocoaNetics article.
參考到
http://goo.gl/1gze29
但是我還是硬加 (下面紅色的是多加的 沒標色的是原本的code)
.h
=========================================================
@interface NSURLRequest (DummyInterface)
+ (BOOL)allowsAnyHTTPSCertificateForHost:(NSString*)host;
+ (void)setAllowsAnyHTTPSCertificate:(BOOL)allow forHost:(NSString*)host;
@end
.m
=========================================================
NSString* httpsURL = @"https://__________";
NSURL* url = [NSURL URLWithString:httpsURL];
NSMutableURLRequest *request = [NSMultableURLRequest requestWithURL:url];
[NSURLRequest setAllowsAnyHTTPSCertificate:YES forHost:[url host]];
[myWebView loadRequest:request];
可以compile過
不知道是否為心理作用 目前為止都有顯示
給大家參考
持續觀察如果還是有失敗會再來更新
謝謝
※ 編輯: donkeychen (210.59.147.226), 04/11/2014 14:59:30
※ 編輯: donkeychen (210.59.147.226), 04/11/2014 14:59:57
※ 編輯: donkeychen (210.59.147.226), 04/11/2014 15:00:30
※ 編輯: donkeychen (210.59.147.226), 04/11/2014 15:01:44
※ 編輯: donkeychen (210.59.147.226), 04/11/2014 15:02:23
→ donkeychen:改這樣後沒有出問題...(目前為止) 04/18 12:04