How to force UIWebView to load before transition

随声附和 提交于 2019-12-08 03:42:03

问题


iOS 6.1

When a button is tapped, I want to perform a transition from an imageview to a webview. The problem is that the very first time the webview loads, the page is white and the html page loads after the transition:

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

How can I force the html page to be loaded before the transition?


回答1:


you can also use this WebContentView library.

this library have one method named as

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

You can use this method to preload the content so that it will render fast.

hope it helps.

Here is the useful link that will help you

Preloading a UIWebView, avoiding white screen flash




回答2:


You have to set delegate of UIWebView and when - (void)webViewDidFinishLoad:(UIWebView *)webView; will called then call your method for transition

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


来源:https://stackoverflow.com/questions/18437792/how-to-force-uiwebview-to-load-before-transition

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