3
版本:XCode的6.1的β可以從共享點URL工作WKWebView?
後端信息:SharePoint 2013
例懷疑代碼下面
電話viewDidLoad中
WKWebViewConfiguration *theConfiguration = [[WKWebViewConfiguration alloc] init];
WKWebView *webView = [[WKWebView alloc] initWithFrame:self.eyWebView.frame configuration:theConfiguration];
webView.navigationDelegate = self;
NSString *eUrl = [[EYUtility share] encodingUrlWithString:<-sharepoint url->;
NSURLRequest *request = [NSURLRequest requestWithURL:[NSURL URLWithString:eUrl]];
[self.view addSubview:webView];
[webView loadRequest:request];
後viewDidLoad中開始呼叫到didReceiveAuthenticationChallenge
-(void)webView:(WKWebView *)webView didReceiveAuthenticationChallenge:(NSURLAuthenticationChallenge *)challenge completionHandler:(void (^)(NSURLSessionAuthChallengeDisposition, NSURLCredential *))completionHandler{
if (challenge.previousFailureCount == 0){
NSURLCredentialPersistence persistence = NSURLCredentialPersistenceForSession;
NSURLCredential *credential = [NSURLCredential credentialWithUser:@"username" password:@"password" persistence:persistence];
completionHandler(NSURLSessionAuthChallengeUseCredential,credential);
}
else{
NSLog(@"%s: challenge.error = %@", __FUNCTION__, challenge.error);
completionHandler(NSURLSessionAuthChallengeCancelAuthenticationChallenge, nil);
}
}
呼叫認證挑戰後,調用didFinishNavigation。 wkWebview顯示「請稍候......」。未顯示來自共享點網址。
爲什麼不從共享點URL顯示它。
的OP要求與WKWebView的例子雖然不是一個UIWebView。 – dawebber 2014-12-29 22:26:41