如何在转换之前强制加载UIWebView

iOS 6.1

当点击一个button时,我想执行从一个ImageView到一个WebView的过渡。 问题是,第一次加载webview,页面是白色的,转换的HTML页面加载:

NepContainerView *containerInFrame = (NepContainerView *)[self view]; UIWebView *webView = [[UIWebView alloc] initWithFrame:self.view.frame]; [webView loadHTMLString:html baseURL:nil]; [UIView transitionWithView:containerInFrame duration:DURATION_TRANS_PHOTO_DESC options:UIViewAnimationOptionTransitionFlipFromLeft animations:^{ [containerInFrame addSubview:webView]; [sender setTitle:@" Photo "]; } completion:NULL]; 

我如何强制HTML页面在转换之前加载?

你也可以使用这个WebContentView库。

这个库有一个名为的方法

 + (void)preloadContent:(NSString *)content; 

您可以使用此方法预加载内容,以便快速渲染。

希望能帮助到你。

这是有用的链接,将帮助你

预加载UIWebView,避免白屏闪烁

您必须设置UIWebView的委托,以及何时- (void)webViewDidFinishLoad:(UIWebView *)webView; 将调用然后调用你的方法进行转换

 [UIView transitionWithView:containerInFrame duration:DURATION_TRANS_PHOTO_DESC options:UIViewAnimationOptionTransitionFlipFromLeft animations:^{ [containerInFrame addSubview:webView]; [sender setTitle:@" Photo "]; } completion:NULL];