1

iOS 6.1

点击按钮时,我想执行从图像视图到 Web 视图的转换。问题是 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 页面?

4

2 回答 2

1

你也可以使用这个WebContentView库。

这个库有一个名为的方法

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

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

希望能帮助到你。

这是有用的链接,可以帮助您

预加载一个UIWebView,避免白屏闪烁

于 2013-08-26T06:28:01.647 回答
0

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

[UIView transitionWithView:containerInFrame
                      duration:DURATION_TRANS_PHOTO_DESC
                       options:UIViewAnimationOptionTransitionFlipFromLeft
                    animations:^{
                        [containerInFrame addSubview:webView];
                        [sender setTitle:@" Photo "];
                    }
                    completion:NULL];
于 2013-08-26T06:31:29.887 回答