2010-06-18 21 views
0

在我的应用程序中,我需要放置一些我从解析数据中获得的文本。目前我正在将它放在一个标签中。问题是将会出现一些html标签,用于指明该明文中的图像[及其网址]和视频等。处理这些识别图像和视频标签并将相应的图像和视频与其他明文一起动态放置的方法是什么?确定图像,文字视频的html标签,并将其转换为图像,动态放置时的视频

编辑:

假设我有以下文字

<img alt="" src="http://www.abc.com/editorial/wp-content/uploads/2010/05/hattos-150x150.jpg" title="Graduation" class="alignnone" width="150" height="150" /> 
For many, graduation is the time when they start thinking of their career planning. Many of you know that they want to make a difference, but don't know how to go past that statement. 

然后在显示我想要显示的地方

<img alt="" src="http://www.abc.com/editorial/wp-content/uploads/2010/05/hattoss-150x150.jpg" title="Graduation" class="alignnone" width="150" height="150" /> 

和 显示的URL指定的图像

For many, graduation is the time when they start thinking of their career planning. Many of you know that they want to make a difference, but don't know how to go past that statement. 

,因为它低于图像。这应该在运行时发生。可能还有一个视频网址代替图片网址。

Thanx提前。

+0

这个问题并不清楚。你得到什么样的数据? 为什么有一个URL?这个标签是什么?你能发布一个示例代码库来理解吗? – 2010-06-18 06:30:58

+0

我得到的数据是明文数据。在这些数据中,将会嵌入标签,如 MyImage。因此,在显示文本时,我需要保持纯文本数据原样,并将html标记中指示的图像显示为图像。这应该在运行时发生。 – neha 2010-06-18 06:38:36

+0

@neha首先,img元素没有结束标记(),所以图片标记不会包含像这样的文字。你**可以**使用alt-text。你的问题还不清楚。你是否试图说:“你如何显示图像**并且**在页面上显示alt-text?” – 2010-06-18 07:54:43

回答

0

如果您看到“img”元素,请创建您的自定义DetailView。在“详细信息”视图中,使用[[element attributes] objectForKey:@"src"];传递将在“img”元素的attributes属性中找到的地址。使用地址下载并填充UIImage。 <p>元素中的内容(您的示例中缺少块标签)可以传递给UILabelUITextView,以适当的值为准。如果看到视频标签,请使用带“src”属性的initWithContentURL:创建MPMoviePlayerController,并将其推入视图堆栈。

相关问题