user440096
user440096

Reputation:

UIWebview is drawing <br/> amongst the rest of the text

The HTML string i get has this in it. <br/> This then gets drawn by the UIWebView as
amongst the rest of the text.

When i NSLog the string that contains the html it contains

&lt;br/&gt; 

in the place of where the
appears in the UIWebView.

Why does this happen? If its valid HTML should the UIWebview drop to a new line rather than draw that?

Anybody able to suggest a fix for this problem?

Many Thanks, -Code

EDIT

Here is the code of me using the UIWebView

    aWebView2 = [[UIWebView alloc] initWithFrame:CGRectMake(0, 45+offset+cumlativeOffset,480 , 50)];//init and create the UIWebView

aWebView2.autoresizesSubviews = YES;
aWebView2.autoresizingMask=(UIViewAutoresizingFlexibleHeight | UIViewAutoresizingFlexibleWidth);
[aWebView2 setBackgroundColor:[UIColor clearColor]];
[aWebView2 setOpaque:NO];

[aWebView2 setDelegate:self];
NSMutableString * indicationAndDose2 = [[NSMutableString alloc] init];
[indicationAndDose2 appendString:@"<html><style type=\"text/css\">"
"html {-webkit-text-size-adjust:90%;color:#145e59; background-color:white }"
"body {font-family:\"Helvetica\"}"
"</style><body>"];
[indicationAndDose2 appendString:@"<b>CONTRAINDICATIONS:</b>"];
NSLog(@"v1x");
[indicationAndDose2 appendString:theMonograph.contra_indications];
[aWebView2 loadHTMLString:indicationAndDose2 baseURL:nil];
[[[aWebView2 subviews] lastObject] setScrollEnabled:NO]; 
NSLog(@"v1y");  
[scrollview addSubview:aWebView2];

Thanks again, -Code

Upvotes: 1

Views: 373

Answers (1)

Pavel
Pavel

Reputation: 930

How do you fill this string var - "theMonograph.contra_indications"? Seams its already contain url-encoded chars (&lt,&gt).

About url strings encoding/decoding you can check this methods:

stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding
stringByReplacingPercentEscapesUsingEncoding

CFURLCreateStringByAddingPercentEscapes
CFURLCreateStringByReplacingPercentEscapes

Upvotes: 1

Related Questions