Advertise Mobile SDKs Books Events Forum News Social Networking Support Us
Follow @iphonedevsdk on Twitter

Interface 2, Advanced iOS
Mockup & Code Gen
($9.99)

Make your own iPhone apps
and run them live!
(free)

Pic Frame Dynamo: Photo Editing
($0.99)

Abiliator
($1.99)

Want your application or service advertised on iPhone Dev SDK?

Go Back   iPhone Dev SDK Forum > iPhone SDK Development Forums > iPhone SDK Development

Reply
 
LinkBack Thread Tools Display Modes
Old 05-25-2011, 10:35 AM   #1 (permalink)
Awesome
 
Esko2300's Avatar
 
Join Date: Jun 2009
Location: New York, N.Y.
Posts: 389
Esko2300 is on a distinguished road
Default Can i display a String in html format?

Ok heres the situation. I grab various strings from the server and display it on screen. Now what i want to do is Display Any strings that come in with html tags in html format.
Example:
Say i get the string <b>Hello World</b> from the server. Now i want to display the String Hello World in Bold format in a UILabel. Is there a way for me to do this? or do i have to write my own string functions that would search for a Html tag and convert the String accordingly.
Esko2300 is offline   Reply With Quote
Old 05-25-2011, 10:41 AM   #2 (permalink)
Registered Member
 
Join Date: Dec 2008
Location: UK
Posts: 1,896
harrytheshark is on a distinguished road
Default

Take a look at this project on GitHub. It takes HTML, parses it, then uses Core Text to actually draw it with the various styles.

https://github.com/Cocoanetics/NSAtt...tions-for-HTML
harrytheshark is offline   Reply With Quote
Old 05-25-2011, 10:48 AM   #3 (permalink)
Nuisance Developer
 
Join Date: Jul 2009
Location: Italy
Posts: 4,691
dany_dev is on a distinguished road
Default

or you can consider to use a standard UIWebView.
__________________
dany_dev is offline   Reply With Quote
Old 05-25-2011, 12:29 PM   #4 (permalink)
Awesome
 
Esko2300's Avatar
 
Join Date: Jun 2009
Location: New York, N.Y.
Posts: 389
Esko2300 is on a distinguished road
Default

Quote:
Originally Posted by dany_dev View Post
or you can consider to use a standard UIWebView.
Ok so how would i do that? Would i just place a UILabel over a UIWEbview but i dont know how that would even work correctly. Im taking various values from the server and some happen to have HTML Properties to it. I guess what im asking is how would i go about Displaying a String in a UIWebView? cause all i see is ways to display webpages and not an string
Esko2300 is offline   Reply With Quote
Old 05-25-2011, 12:55 PM   #5 (permalink)
Nuisance Developer
 
Join Date: Jul 2009
Location: Italy
Posts: 4,691
dany_dev is on a distinguished road
Default

Quote:
Originally Posted by Esko2300 View Post
Ok so how would i do that? Would i just place a UILabel over a UIWEbview but i dont know how that would even work correctly. Im taking various values from the server and some happen to have HTML Properties to it. I guess what im asking is how would i go about Displaying a String in a UIWebView? cause all i see is ways to display webpages and not an string
something like

Code:
NSString *html = [NSString stringWithFormat:@"<html> <head><title></title></head><body><p align=\"left\">%@</p></body></html>",yourFormattedString];
	
html = [html stringByReplacingOccurrencesOfString:@"\n" withString:@"<br/>"];  
	
[yourWebView loadHTMLString:html baseURL:nil];
__________________
dany_dev is offline   Reply With Quote
Old 05-27-2011, 08:38 AM   #6 (permalink)
Awesome
 
Esko2300's Avatar
 
Join Date: Jun 2009
Location: New York, N.Y.
Posts: 389
Esko2300 is on a distinguished road
Default

Quote:
Originally Posted by dany_dev View Post
something like

Code:
NSString *html = [NSString stringWithFormat:@"<html> <head><title></title></head><body><p align=\"left\">%@</p></body></html>",yourFormattedString];
	
html = [html stringByReplacingOccurrencesOfString:@"\n" withString:@"<br/>"];  
	
[yourWebView loadHTMLString:html baseURL:nil];
Cool thanks ill check it out today and tell you how it went
Esko2300 is offline   Reply With Quote
Reply

Bookmarks

Tags
html, uilabel

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



» Advertisements
» Online Users: 347
6 members and 341 guests
doffing81, dre, iOS.Lover, jenniead38, Kirkout, Wikiboo
Most users ever online was 1,387, 04-10-2012 at 04:21 AM.
» Stats
Members: 175,663
Threads: 94,120
Posts: 402,898
Top Poster: BrianSlick (7,990)
Welcome to our newest member, LezB44
Powered by vBadvanced CMPS v3.1.0

All times are GMT -5. The time now is 02:10 AM.
Powered by vBulletin® Version 3.8.0
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.3.0