除非两次调用此代码,否则 iOS UIWebView 标题不会更新 [英] iOS UIWebView title doesn't update unless calling this code twice

查看:70
本文介绍了除非两次调用此代码,否则 iOS UIWebView 标题不会更新的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

网页标题不会更新,除非我调用该方法两次

Webpage title doesn't update unless I call the method twice

NSURL *yourURL = [NSURL URLWithString: webpageURLLabel.text ];
NSURLRequest *request = [[NSURLRequest alloc] initWithURL:yourURL];
[webpagePreview loadRequest:request];
webpagePreview.scalesPageToFit = YES;
webpageTitleLabel.text = [webpagePreview stringByEvaluatingJavaScriptFromString:@"document.title"];

有关如何解决此问题的任何建议?

Any suggestions on how to fix this?

推荐答案

- (void)webViewDidFinishLoad:(UIWebView *)webView
{
    webpageTitleLabel.text = [webpagePreview stringByEvaluatingJavaScriptFromString:@"document.title"];
}

上面的代码解决了我的问题.

The above code fixed my issue.

这篇关于除非两次调用此代码,否则 iOS UIWebView 标题不会更新的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆