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 th开发者_StackOverflow中文版is should happen at runtime. There might also be a video url in place of image url.
Thanx in advance.
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.
精彩评论