Last active
December 18, 2015 20:59
-
-
Save matt-curtis/5843862 to your computer and use it in GitHub Desktop.
Redraw/relayout UIWebView's Webkit DOM
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
- (void) forceRedrawInWebView:(UIWebView*)webView { | |
NSArray *views = webView.scrollView.subviews; | |
for(int i = 0; i<views.count; i++){ | |
UIView *view = views[i]; | |
//if([NSStringFromClass([view class]) isEqualToString:@"UIWebBrowserView"]){ | |
[view setNeedsDisplayInRect:webView.bounds]; // Webkit Repaint, usually fast | |
[view setNeedsLayout]; // Webkit Relayout (slower than repaint) | |
// Causes redraw & relayout of *entire* UIWebView, onscreen and off, usually intensive | |
[view setNeedsDisplay]; | |
[view setNeedsLayout]; | |
// break; // glass in case of if statement (thanks Jake) | |
//} | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Javascript counterpart - will in some cases suffice and do the same thing. | |
window.scrollBy(1, 1); | |
window.scrollBy(-1, -1); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Stack Overflow Question/Answer http://stackoverflow.com/a/17257650/183471