如何摆脱 UIWebView 中蓝色方块中的问号? [英] How to get rid from question mark in a blue square in UIWebView?

查看:29
本文介绍了如何摆脱 UIWebView 中蓝色方块中的问号?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我的 iPhone 应用程序中,我正在解析 RSS 提要以获取 html 并保留它.之后我在 UIWebView 中显示这个 html.问题是 html 包含图像的 url,如果有网络连接,一切正常,UIWebView 加载并显示这些图像,但如果没有连接,它会显示文本,但在图像的位置显示内部带有蓝色方块的框架

In my iPhone application I'm parsing RSS feed to get html and keep it. Afterwards I display this html in UIWebView. The problem is that html contains urls of images, if there is network connection everything is ok, UIWebView loads and displays these images, but if there is no connection it shows text but in place of images shows frame with blue square inside

我怎样才能摆脱它?谢谢

How can I get rid of it? Thank you

推荐答案

以编程方式检查以确保您有互联网连接.

Check programmatically to make sure that you have an internet connection.

请参阅此问题以及关于如何做到这一点的公认答案.

See this question and its accepted answer on how to do that.

如果您没有互联网连接,那么您有几个选择.您可以:

If you don't have an internet connection, then you have a couple of options. You can either:

  1. 解析您的 html,将 <img> 标签替换为空白(这将完全摆脱图像及其相关的蓝色问号框.
  2. 解析您的 html,将 <img src="somewebsite"> 的 src 部分替换为对项目包中的图像占位符的引用.
  1. Parse through your html, replace the <img> tags with blanks (this will completely get rid of the images and their associated blue question mark boxes.
  2. Parse through your html, replace the src part of <img src="somewebsite"> with a reference to an image placeholder in the project bundle.

XPath 是您解析 html 的朋友.尽管如果您愿意,您可以使用 NSSTring 完成所有这些工作.

XPath is your friend when it comes to parsing html. Although if you wanted to, you could do all of this with NSSTring.

这篇关于如何摆脱 UIWebView 中蓝色方块中的问号?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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