加载失败
解决方法: 调用- (void)webView:(UIWebView *)webView didFailLoadWithError:(NSError *)error
在代理方法里面打印错误信息 NSLog(@"%@",[error localizedDescription]);
例:错误码为101, 错误原因 URL 网址涉及中文字符参数, 需要转码 :
NSString *encodedString = [strUrl stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
URL 转字符串
NSString *urlString = [url absoluteString];
汉字转 UTF8
NSString *urlEncode = [url stringByAddingPercentEncodingWithAllowedCharacters:[NSCharacterSet characterSetWithCharactersInString:url]];
UTF8 转汉字
[str stringByRemovingPercentEncoding];
获取高度
[[webView stringByEvaluatingJavaScriptFromString:@"document.body.offsetHeight;"] intValue];
特殊符号 UTF8 编码
普通的编码只能对于汉字
- (NSString *)CFBridgingRelease(CFURLCreateStringByAddingPercentEscapes(NULL, (CFStringRef)[AccountManager sharedAccountManager].accountInfo.token, NULL, (CFStringRef)@"!*'();:@&=+ $,/?%#[]", kCFStringEncodingUTF8))
网友评论