Authored by gaoqiang xu

优化url加载

... ... @@ -45,7 +45,16 @@
- (void)setUrl:(NSString *)url
{
_url = url.length>0?[url stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding]:url;
// 检验url是否能正常转成NSURL,防止webview不能加载
BOOL isValidUrl = ([NSURL URLWithString:url] != nil);
if (url.length > 0
&& !isValidUrl) {
// 如果url里面含有需要转码的字符,则这里进行一次编码
_url = [url stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
} else {
_url = url;
}
}
- (void)didMoveToSuperview
... ...