I am parsing a group of post on a blog.
I have some HTML that I successfully assigned to a string. I am trying to get the HTML to display in a UITableview. However, I want it formatted.
For instance I want <br /> to actually do a line break in the table and <img scr= to actually display the picture. How can I accomplish this.
Don't ever ever ever use UIWebView in UITableView. It won't end well.
You should check out the Three20 project's TTStyledTextLabel, which will do some basic HTML formatting. I have used it with good results in the past.
Related
I am working at revamping some previous blog apps. I parse the XML, but so far, when a table view cell is clicked, I just have it open the URL for the article that was clicked by the user. This is beginning to get frowned upon by Apple, and I need to change it anyways, so I can gain some more options with display. The entire article is displayed with this tag:
<content:encoded>
I am able to get the data from within this tag, but there are a couple issues. It always starts off with
<![CDATA[<p>
And ends with
</p>]]>
As you can see, it also contains not true text but code, such as
<p> and </p> and aren’t “
Any suggestions for how I can parse this to remove the beginning and ends of the string, and convert to all true text that I can load in my view?
i got an rss feed app. All is working ok apart from the fact that in my "description" textView
(detail of the rss) the text appears in html!
any ideas in what is going on?
thanks!
i have found the solution using a wbview with loadHTMLString.
however i would like to ask what is the difference between these two rss feeds:
http://newsrss.bbc.co.uk/rss/sportonline_world_edition/front_page/rss.xml
and this for example:
http://feeds.feedburner.com/pitsirikos/uPfN
in the first one i can get the textview to display the contents as they should appear while in the second one i get html code in the textview!
my code remains the same in both cases...
The key difference between them is that the latter contains prefix tags
e.g. and
Do you use NSXMLParser or libxml2 ? are you doing a strcmp with the element name ?
I think the title explain my quesion. I need to add a link (or a button) in a label/span (never understand the real difference) by using Struts2 tags.
<s:label cssClass="menu_span">
<s:submit value="Login" />
</s:label>
This doesnt work. Also, i didnt see the s:span (like s:html, s:body, s:head, s:title, s:img, and so on...)
I tried to watch the tag references, but seems that isnt possible do it!
Thanks
First, you don't need to use Struts2 tags where standard HTML tags work fine (which is why there isn't an s:html tag, etc.) Tag libraries in JSP are there to simplify and standardize your HTML output to make it easier on you. When the tag syntax is practically the same as the output generated, they cease to be useful.
Second, what are you trying to achieve by wrapping a submit button in a label? Labels are used to associate text with a form element such as a radio button, checkbox, text field, etc. Buttons are already clickable, so I don't follow what you are trying to do.
I'm new to the whole "iPhone Dev" world, and I am creating a simple app which has a feature to see the latest entries from a number of different Wordpress blogs.
I am able to grab encoded content ( node) from the RSS feeds and display it easily enough using a UIWebView and the loadHTMLString function.
What I cannot figure out how to do right now is change the look of the text in any way, shape, or form... I don't think it's possible for me to change the data coming back in the RSS feed, so I need to know how to do it in the code.
Thanks!
--d
There are at least two ways to change the appearance.
One is to modify the html before passing it to loadHTMLString. For example, you could insert a <link href="local.css" rel="stylesheet" type="text/css"> just before </head> using simple string replacement. You could do the same thing with a <style>...</style> tag.
html = [html stringByReplacingOccurrencesOfString:#"</head>" withString:#"<link ... /></head>"];
Another way is to call stringByEvaluatingJavaScriptFromString in webViewDidFinishLoad and do whatever you want with javascript. You have full access to the DOM through javascript and can manually create styles and assign classes.
You may need to use both together.
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.
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.