UIWebView gets cleared after dismissing a fullscreen modal

我是研究僧i 提交于 2019-12-20 07:37:07

问题


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:


[self presentModalViewController:ImageView animated:YES];

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



来源:https://stackoverflow.com/questions/3952047/uiwebview-gets-cleared-after-dismissing-a-fullscreen-modal

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!