【问题标题】:How to open webView with a data (html page) I got as response from get/post request?如何使用我从 get/post 请求获得的数据(html 页面)打开 webView?
【发布时间】:2015-11-12 06:22:01
【问题描述】:

我发送 get/post http 请求,作为响应,我收到带有页面 html 源代码的字符串。

如何在 webView 中加载或显示此页面?

例如响应示例(现在有错误,但会是正确的页面):

<html>
<head><title>400 Bad Request</title></head>
<body bgcolor="white">
<center><h1>400 Bad Request</h1></center>
<hr><center>cloudflare-nginx</center>
</body>
</html>

谢谢

【问题讨论】:

    标签: html objective-c webview


    【解决方案1】:

    就这么简单

    NSString *html = your html content here;  
    [webView loadHTMLString:html baseURL:nil];
    

    如果您的文本中没有 html 标记,请将其更改为下面

    NSString *html = [NSString stringWithFormat:@"<html><body>%@</body></html>", your html content here];  
    

    【讨论】:

    • 哦,太好了,谢谢。我以为这很简单,但不知道怎么做)
    猜你喜欢
    • 2019-11-25
    • 1970-01-01
    • 1970-01-01
    • 2017-12-31
    • 2013-05-12
    • 2013-11-01
    • 1970-01-01
    • 2017-01-13
    • 2014-05-31
    相关资源
    最近更新 更多