解除全屏模式后,UIWebView将被清除 [英] UIWebView gets cleared after dismissing a fullscreen modal

查看:81
本文介绍了解除全屏模式后,UIWebView将被清除的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个UIWebView,它在viewDidLoad上加载一个html字符串。它检测用户是否单击链接并显示模态视图,但是当我关闭模态视图时,UIWebView的html已经消失了!如果我使用FormSheet模式样式,内容会留下,它唯一的全屏模式会导致这种情况。显然我可以在viewWillAppear上再次输入html字符串来修复它,但是这会导致内容重新回到我不想要的状态。继承我的代码:

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;
   }

}

如果我改变'return NO; 'to'返回YES;'webView内容保持不变,但显然它会加载图像。

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

任何帮助?

谢谢

推荐答案

[self presentModalViewController:ImageView animated:YES] ;

[self presentModalViewController:ImageView animated:YES];

看起来你正在进行类调用而不是ImageView上的实例调用。

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

这篇关于解除全屏模式后,UIWebView将被清除的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆