版本:XCode 6.1 beta
后端: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显示“Please wait ...”。没有从共享点网址显示。
为什么不从共享点网址显示它。
答案 0 :(得分:0)
这里我使用UIWebview和CustomHTTPProtocol类。它将从sharepoint网址开始工作。
https://developer.apple.com/library/ios/samplecode/CustomHTTPProtocol/Introduction/Intro.html
欢呼: - )