Sac*_*uja 5 iframe uiwebview ios
iFrame在iOS 7中呈现,但在iOS 8中,嵌入的iFrame请求UIWeview失败error 999(取消).似乎iFrame请求在主要请求仍在进行时被取消(webView.isLoading返回TRUE).因此,它在Web视图中显示空格而不是iFrame.
此问题特定于iOS 8.请提供代码段,以便在Web视图(iOS 8)中成功呈现iFrame.
NSString *HTML = [NSString stringWithFormat:@"<html> \n"
"<head> \n"
"<style type=\"text/css\">\n"
"iframe { max-width: 100%%; width: auto; height: auto; }"
"img { max-width: 100%%; width: auto; height: auto; }" ....];
[cell.webView loadHTMLString:HTML baseURL:[NSURL URLWithString:@"http://"]];
Run Code Online (Sandbox Code Playgroud)
然后,在自定义单元格(单元格)中调用webView委托函数: -
- (BOOL)webView:(UIWebView *)webView shouldStartLoadWithRequest:(NSURLRequest *)request navigationType:(UIWebViewNavigationType)navigationType {
return YES;
}
- (void)webViewDidFinishLoad:(UIWebView *)webView {
…
}
- (void)webView:(UIWebView *)webView didFailLoadWithError:(NSError *)error{
NSLog(@"%@",error);
}
Run Code Online (Sandbox Code Playgroud)
在IOS 8,iFrame的请求发起在shouldStartLoadWithRequest和失败中didFailLoadWithError有error 999:
Error Domain=NSURLErrorDomain Code=-999 "The operation couldn’t be completed. (NSURLErrorDomain error -999.)" UserInfo=0x7ff6cb609580 {NSErrorFailingURLStringKey
Run Code Online (Sandbox Code Playgroud)
此时,webView.isLoading由于主要请求仍未完成,因此为真.主请求完成后有没有办法调用iFrame请求?
| 归档时间: |
|
| 查看次数: |
1307 次 |
| 最近记录: |