使网页滑动顺畅
self.webView.scrollView.decelerationRate = UIScrollViewDecelerationRateNormal;
如果点击加载网页后,左滑返回上一界面手势失效,试过这种方法都无效,可能使前端web 宽度设置问题。
如果在网页请求失败后,想在
- (void)webView:(UIWebView *)webView didFailLoadWithError:(NSError *)error
,
但如果在请求过程中左滑返回,也会走didFailLoadWithError
代理方法,这时可以判断 error code
if ([error code] == NSURLErrorCancelled) return;
设置Agent
NSDictionary *infoDic = [[NSBundle mainBundle] infoDictionary];
NSString *paramsString = [NSString stringWithFormat:@"AppName/%@",[infoDic objectForKey:@"CFBundleShortVersionString"]];
NSDictionary *dictionary = @{@"UserAgent": paramsString};
[[NSUserDefaults standardUserDefaults] registerDefaults:dictionary];
[url scheme]
[url host]
[url port]
[url absoluteString]
等相关概念区分,
NSURL官方文档
网友评论