Question

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?

Was it helpful?

Solution

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

OTHER TIPS

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];
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top