实战示例:indexvue
(2) 去除网页title—页面不启用系统导航即可
示例:pagesjson
备注 :常见问题请移步: web-view加载网络html页面的实现及问题
需要用到回调
webViewsetWebChromeClient(new WebChromeClient()
{
@Override
public void onReceivedTitle(WebView view, String aTitle)
{
// 设置当前activity的标题栏
titlesetText(aTitle);
superonReceivedTitle(view, aTitle);
}
});
WKWebView 的estimatedProgress和title 都是KVO模式,所以可以添加监听:
[webView addObserver:self forKeyPath:@"estimatedProgress" options:NSKeyValueObservingOptionNew context:NULL];
[webView addObserver:self forKeyPath:@"title" options:NSKeyValueObservingOptionNew context:NULL];
监听的实现方法:
- (void)observeValueForKeyPath:(NSString )keyPath ofObject:(id)object change:(NSDictionary )change context:(void )context {
if ([keyPath isEqualToString:@"estimatedProgress"]) {
if (object == webView) {
[selfprogressView setAlpha:10f];
[selfprogressView setProgress:selfcurrentSubViewwebViewestimatedProgress animated:YES];
if(selfcurrentSubViewwebViewestimatedProgress >= 10f) {
[UIView animateWithDuration:03 delay:03 options:UIViewAnimationOptionCurveEaseOut animations:^{
[selfprogressView setAlpha:00f];
} completion:^(BOOL finished) {
[selfprogressView setProgress:00f animated:NO];
}];
}
}
else
{
[super observeValueForKeyPath:keyPath ofObject:object change:change context:context];
}
}
else if ([keyPath isEqualToString:@"title"])
{
if (object == selfwebView) {
selftitle = selfwebViewtitle;
}
else
{
[super observeValueForKeyPath:keyPath ofObject:object change:change context:context];
}
}
else {
[super observeValueForKeyPath:keyPath ofObject:object change:change context:context];
}
}
进度条增加了动画,类似safari的进度效果
注意销毁时一定要移除监听
[webView removeObserver:self forKeyPath:@"estimatedProgress"];
[webView removeObserver:self forKeyPath:@"title"];
以上就是关于使用web-view组件内嵌网页并去除网页title全部的内容,包括:使用web-view组件内嵌网页并去除网页title、android开发webview的gettitle()不等于“XXX”geturl()也不等“xxx”、如何在WKWebView中显示进度条及HTML的title等相关内容解答,如果想了解更多相关内容,可以关注我们,你们的支持是我们更新的动力!
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)