views:

70

answers:

1

I have a UIWebView which loads a html string on viewDidLoad. It detects if the user clicks a link and display a modal view, but when i close the modal view the UIWebView's html has gone! If i use a FormSheet Modal Style the content stays behind, its only fullscreen modals that cause this. Obviously i can just input the html string again on viewWillAppear which fixes it but this causes makes the content flick back on which i don't want. heres my code:

-(void)viewDidLoad {
    [self loadArticleText];
...
}

-(void)loadArticleText {
   NSString *htmlHead = @"<html><head>...";
   NSString *htmlFoot = @"</body></html>";
   NSString *htmlContent = [self.articleData valueForKey:@"fulltext"];

   NSString *html = [[NSString alloc] initWithFormat:@"%@%@%@", htmlHead, htmlContent, htmlFoot];

   [self.articleView loadHTMLString:html baseURL:nil];
   [html release];
}

- (BOOL)webView:(UIWebView*)webView shouldStartLoadWithRequest:(NSURLRequest*)request navigationType:(UIWebViewNavigationType)navigationType {
   if (navigationType == UIWebViewNavigationTypeLinkClicked) {
       NSURL *URL = [request URL];          
       ImageViewer *imageView = [[[ImageViewer alloc] initWithNibName:@"ImageViewer" bundle:nil] autorelease];
       imageView.imageURL = URL;
       [self presentModalViewController:imageView animated:YES];
       return NO; 
   } else {
       return YES;
   }

}

If i change 'return NO;' to 'return YES;' the webView contents stays, like it should, but obviously it loads the image.

Any help??

Thanks

A: 

[self presentModalViewController:ImageView animated:YES];

It looks like you are making a class call rather than an instance call on ImageView.

Christopher Farnell
Thats just a typo in my question the actual code is correct. fixed the question!The problem is not with loading the modal its after the modal gets dismissed the UIWebViews content has gone/released/vanished, as i said if i return YES; after presenting the modal the UIWebViews contents stays but it loads the url to the image, which i don't want.
swaterfall