识别文本中图像、视频的html标签,并在动态放置时将其转换为图像、视频

发布于 2024-09-05 19:36:18 字数 1047 浏览 5 评论 0原文

在我的应用程序中,我需要放置一些从解析数据中获取的文本。目前我正在将它放在标签中。问题是,在该明文中将会有一些 html 标签指示图像 [及其 url] 和视频等。处理这种识别图像和视频标签并动态地将相应的图像和视频与其余明文一起放置的好方法是什么?

编辑:

假设我有以下文本

<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.

然后在显示时我想显示由 url 指示的图像来代替

<img alt="" src="http://www.abc.com/editorial/wp-content/uploads/2010/05/hattoss-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.

为图像下方。这应该在运行时发生。也可能有视频 url 代替图像 url。

提前致谢。

In my app I need to lay some text which I'm getting from a parsed data. Currently I'm currently laying it in a label. The problem is there are going to be some html tags indicating an image [along with its url] and videos etc in that plaintext. What is a good way to handle this identifying images and videos tags and laying corresponding images and videos along with rest of the plaintext dynamically?

EDIT:

Suppose I'm having following text

<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.

Then while displaying I want to display an image indicated by the url in place of

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

and
display

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.

as it is below the image. And this should happen at runtime. There might also be a video url in place of image url.

Thanx in advance.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

匿名的好友 2024-09-12 19:36:18

如果您看到“img”元素,请创建自定义 DetailView。在“详细信息”视图中,使用 [[element attribute] objectForKey:@"src"]; 传递将在“img”元素的 attribute 属性中找到的地址; 使用该地址下载并填充 UIImage

中的内容是元素(示例中缺少块标签)可以传递给 UILabelUITextView (以合适的为准)。如果您看到视频标签,请使用带有“src”属性的 initWithContentURL: 创建一个 MPMoviePlayerController 并将其推送到视图堆栈上。

If you see an "img" element, create your custom DetailView. In your "detail" view, pass the address in which will be found in the attributes property of the "img" element using [[element attributes] objectForKey:@"src"]; Use the address to download and populate a UIImage. The contents in the <p> element (the block tags are missing in your example) can be passed to a UILabel or UITextView whichever is appropriate. If you see a video tag, create an MPMoviePlayerController using initWithContentURL: with the "src" attribute and push onto the view stack.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文