SnK
SnK

Reputation: 528

UIWebview loadHTMLString does not want to show

To fix the UITextview blue color issue for links in ios ( i want white ones) i implemented the UIWebview in my custom popup

in my popup controller i have the following code ( uiwebview is set to hidden in xib)

- (void) showWebView:(NSString *)htmlText{
    [webView setHidden:FALSE];
    [txtContent setHidden:TRUE];

    NSString * htmlString = [NSString stringWithFormat:@"<html><head><style type='text/css'>body {background-color:transparent; } p { color:white; font-family:Helvetica; font-size:14px; } a { color:white; }</style></head><body><p>%@</p></body></html>", htmlText];
    webView.delegate = self;

    NSLog(@"htmlstring  %@",htmlString);
   [webView loadHTMLString:htmlString baseURL:nil];

}

(txtContent is my uiTextview which i'm hiding)

in my main controller i have the following:

SwbPopup * popup =  [[SwbPopup alloc] initWithNibName:@"SwbPopup" bundle:nil];

[[self.view superview] addSubview:popup.view];
popup.view.center = CGPointMake([self.view superview ].center.y, [self.view superview].center.x - ([self.view superview].frame.size.width / 4) );


[popup showWebView:popupBloodglucoseLevel];

(popbloodglucoselevel is a string containing my popupmessage with a link)

When i don't hide webview in the xib it does show (everytime) but don't want to load the html either....

UPDATE i implemented all below delegate methods and none of them get called:s

    - (void)webView:(UIWebView *)webView didFailLoadWithError:(NSError *)error
{   
    //[myActivityIndicatorView stopAnimating];

    NSLog(@"ERROR");
    NSLog([NSString stringWithFormat: @"%d", [error code]]);
}

- (void)webViewDidStartLoad:(UIWebView *)webView{
    NSLog(@"Started loading");
}

- (void)webViewDidFinishLoad:(UIWebView *)webView{
    NSLog(@"Finished loading");

}

Upvotes: 0

Views: 4627

Answers (1)

sergio
sergio

Reputation: 69047

Have you tried implementing

[– webView:didFailLoadWithError:][1]

in your delegate to see what is happening while loading the HTML?

Under iOS5 I found that sometimes a UIWebView would not load its content if

<meta charset="utf-8"></meta>

(or other equivalent charset specification) was not present in the HTML.

Upvotes: 1

Related Questions