Skip to content

Commit b6b3bad

Browse files
committed
Fixed UIWebView issue
1 parent 7376cce commit b6b3bad

File tree

2 files changed

+9
-4
lines changed

2 files changed

+9
-4
lines changed

AMScrollingNavbar/AMScrollingNavbarViewController.m

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -238,8 +238,13 @@ - (void)updateSizingWithDelta:(CGFloat)delta
238238
// Changing the layer's frame avoids UIWebView's glitchiness
239239
frame = self.scrollableView.frame;
240240
frame.size.height = self.scrollableView.superview.frame.size.height - frame.origin.y;
241-
self.scrollableView.layer.frame = frame;
242-
self.scrollableView.frame = frame;
241+
242+
// if the scrolling view is a UIWebView, we need to adjust its scrollview's frame.
243+
if ([self.scrollableView isKindOfClass:[UIWebView class]]) {
244+
((UIWebView*)self.scrollableView).scrollView.frame = frame;
245+
} else {
246+
self.scrollableView.frame = frame;
247+
}
243248
}
244249

245250
- (void)refreshNavbar

ScrollingNavbarDemo/ScrollingNavbarDemo/AMWebViewController.m

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,8 @@ @implementation AMWebViewController
1919
- (void)viewDidLoad
2020
{
2121
[self setTitle:@"Web View"];
22-
// [self.webView setBackgroundColor:[UIColor colorWithRed:0.93 green:0.93 blue:0.93 alpha:1]];
23-
// [self.view setBackgroundColor:[UIColor colorWithRed:0.93 green:0.93 blue:0.93 alpha:1]];
22+
[self.webView setBackgroundColor:[UIColor colorWithRed:0.93 green:0.93 blue:0.93 alpha:1]];
23+
[self.view setBackgroundColor:[UIColor colorWithRed:0.93 green:0.93 blue:0.93 alpha:1]];
2424
NSMutableString* html = [@"<html><head></head><body style='background-color:#eee'>" mutableCopy];
2525

2626
[html appendString:@"<h1>The content</h1><p>Long content here</p><p>Some other content here</p>"];

0 commit comments

Comments
 (0)