Permalink
Browse files

Added white flash fix as suggested by nruffilo in issue #164 (webView…

….opaque = NO and background transparent) + reset the two properties to default values when the user scroll the webview
  • Loading branch information...
1 parent d87e8bb commit 85e15563dc70c6adba116fa07fffcec2947b5f31 @Xm4s Xm4s committed with Sebastian Steinmetz Feb 13, 2012
Showing with 20 additions and 2 deletions.
  1. +2 −0 Classes/RootViewController.h
  2. +18 −2 Classes/RootViewController.m
@@ -73,6 +73,8 @@
UIWebView *currPage;
UIWebView *nextPage;
+ UIColor *webViewBackground;
+
CGRect upTapArea;
CGRect downTapArea;
CGRect leftTapArea;
@@ -130,6 +130,8 @@ - (id)init {
currentPageIsDelayingLoading = YES;
currentPageHasChanged = NO;
currentPageIsLocked = NO;
+
+ webViewBackground = nil;
// ****** LISTENER FOR DOWNLOAD NOTIFICATION
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(downloadBook:) name:@"downloadNotification" object:nil];
@@ -169,6 +171,15 @@ - (id)init {
- (void)setupWebView:(UIWebView *)webView {
NSLog(@"• Setup webView");
+ if (webViewBackground == nil)
+ {
+ webViewBackground = webView.backgroundColor;
+ [webViewBackground retain];
+ }
+
+ webView.backgroundColor = [UIColor clearColor];
+ webView.opaque = NO;
+
webView.delegate = self;
webView.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;
@@ -900,7 +911,7 @@ - (CGRect)frameForPage:(int)page {
}
- (void)scrollViewWillBeginDragging:(UIScrollView *)scroll {
NSLog(@"• Scrollview will begin dragging");
- [self hideStatusBar];
+ [self hideStatusBar];
}
- (void)scrollViewDidEndDragging:(UIScrollView *)scroll willDecelerate:(BOOL)decelerate {
NSLog(@"• Scrollview did end dragging");
@@ -1215,7 +1226,7 @@ - (void)webViewDidAppear:(UIWebView *)webView animating:(BOOL)animating {
NSLog(@" Handle saved hash reference if necessary");
[self handleAnchor:YES];
}
- }
+ }
}
- (void)webView:(UIWebView *)webView dispatchHTMLEvent:(NSString *)event;
{
@@ -1396,6 +1407,9 @@ - (void)userDidTap:(UITouch *)touch {
- (void)userDidScroll:(UITouch *)touch {
NSLog(@"• User scroll");
[self hideStatusBar];
+
+ currPage.backgroundColor = webViewBackground;
+ currPage.opaque = YES;
}
#pragma mark - PAGE SCROLLING
@@ -1697,6 +1711,8 @@ - (void)dealloc {
[nextPage release];
[prevPage release];
+ [webViewBackground release];
+
[super dealloc];
}

0 comments on commit 85e1556

Please sign in to comment.