UIWebView gets cleared after dismissing a fullscre

2020-05-03 10:40发布

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

1条回答
ゆ 、 Hurt°
2楼-- · 2020-05-03 11:03

[self presentModalViewController:ImageView animated:YES];

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

查看更多
登录 后发表回答