You have to escape the '%' in your css code, before you build the NSString stringWithFormat . In case you don't even need a string build from format a simple.
Up vote 0 down vote favorite share g+ share fb share tw.
I'm developing an iOS app who loads the content of a html string with a CSS style sheet into a UIWebView but I have problems when I use the percentage '%' to define the width of a image. It just doesn't work! - (void) loadHTMLContent { NSString *path = NSBundle mainBundle bundlePath; NSURL *baseURL = NSURL fileURLWithPath:path; textFontSize = 120; NSString *imggt; if (item.
Imggt) imggt = NSString stringWithFormat:@"",item. Imggt; else imggt = @""; NSString *cssCode = NSString stringWithFormat:@" \n" "body{ font-family: Georgia; color: #333; margin: 0; padding: 0; line-height: 1.2em; } \n" "h4, h3, h5{ margin: 0 0 5px 0; padding: 0em; text-shadow: 2px 2px 2px rgba(255, 255, 255, 0.8); } \n" "h3{ font-family: Helvetica; font-size: 1.2em; letter-spacing: -1px; } \n" "h3, #autor { color: #00365B; } \n" "h4,h5{ font-weight: normal; font-size: 0.75em; }\n" "h4{ color: #0069AA; } \n" "h5{ text-align:justify; } \n" "#zigzag { height:15px; background-image:url('zigzag. Png');background-repeat:repeat-x; }\n" "#destacados, #cuerpo{ padding: 0 10px; } \n" "#destacados{ background-image:url('fndNoticia.
Png'); padding-bottom: 29px; margin-bottom: 0px; } \n" "#destacados img { width: 97%; text-align:center; margin: 0 auto; border: 8px solid #FFF; } \n" "#fecha_autor{ font-size: 0.75em; border-bottom: 1px solid #D7D7D7; height: 20px; padding-bottom: 8px; margin: 13px 0; } \n" "#fecha{ color: #666;} \n" "#autor{ float: right; } \n" "#texto{ font-size: 0.80em; line-height: 1.2em; text-align:justify; } \n"; NSString *htmlCode = NSString stringWithFormat:@" \n" " \n" " \n" " \n" " \n" //CSS " \n" " \n" " %@ \n" //Category " %@ \n" //Title " %@%@ \n" //Subtitle & Imggt in HTML " \n" " \n" " \n" " \n" " %@ \n" //Date " %@ \n" //Author " \n" " %@ \n" " \n" " %@ \n" //Nielsen code " \n" " \n",cssCode,item. Category,item. Title,item.
Subtitle,imggt,item. PubDate,item. Author,item.
Text stringByReplacingOccurrencesOfString:@"br" withString:@"",AppStaticData getNielsenSiteCensusHTMLImageOfArticle:item. Url; webView loadHTMLString:htmlCode baseURL:baseURL; } The CSS & HTML code tested on a browser works: The problem seems to be here: "#destacados img { width: 97%; text-align:center; margin: 0 auto; border: 8px solid #FFF; } \n" Seems that I can't use percentages to set the value of the image. Why?
Is there other way to escale the original image relatively to the container size? Objective-c css ios uiwebview link|improve this question asked Nov 4 '11 at 8:49Jimmy505 73% accept rate.
You have to escape the '%' in your css code, before you build the NSString stringWithFormat. In case you don't even need a string build from format a simple NSString *cssCode = @"your css {}"; should work.
I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.