Reputation: 9700
So, I have this code in one of my methods, which generates a new random word, displays it in a web view, then animates a page curl to transition from the current word to that new one. Ideally this should curl away the old view, and display the new one on the page beneath.
At present, the animation occurs (the page curls), then the new content loads after it's finished curling (meaning that the page below the curl has the old word on it until the curl is done, at which point the new one appears). I have no idea why this is, anyone able to explain it to me? Is it something to do with the data not coming back from my [dictionary]
object fast enough, perhaps?
NSString *word = [dictionary randomWord];
NSString *htmlDefinition = [dictionary getHTMLFor: word];
[self.randomDefinitionWebView loadHTMLString: htmlDefinition baseURL: nil];
[UIView transitionWithView: self.randomDefinitionWebView
duration: 1.5
options: UIViewAnimationOptionTransitionCurlDown
animations: ^ { }
completion: nil];
}
Upvotes: 0
Views: 83
Reputation: 1427
UIWebview loads HTML in another thread. And when it finishes, it tells its delegate webViewDidFinishLoad:
So the animations will be shown first.
You can set the webview's delegate to yourself and do animations in webViewDidFinishLoad:
Upvotes: 3