From b664cb5be844015456db5bfd0ed0368865c1f111 Mon Sep 17 00:00:00 2001 From: Kian Cheong Lim Date: Sat, 2 Feb 2013 10:17:53 +0800 Subject: [PATCH 1/2] Enable UIWebView's scalesPageToFit #001 --- MMWebViewWithSmartHeader/RootViewController.m | 1 + 1 file changed, 1 insertion(+) diff --git a/MMWebViewWithSmartHeader/RootViewController.m b/MMWebViewWithSmartHeader/RootViewController.m index c212407..d45608b 100644 --- a/MMWebViewWithSmartHeader/RootViewController.m +++ b/MMWebViewWithSmartHeader/RootViewController.m @@ -33,6 +33,7 @@ - (void)viewDidLoad [super viewDidLoad]; self.smartView = [[MMSmartHeaderWebView alloc] initWithFrame:self.view.frame header:self.headerView]; + self.smartView.scalesPageToFit = YES; [self.view addSubview:smartView]; [smartView loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString: @"http://michaelmanesh.com"]]]; } From 3f07a2ae2cbb08407e5058908a15a539e808b552 Mon Sep 17 00:00:00 2001 From: Kian Cheong Lim Date: Sat, 2 Feb 2013 10:18:44 +0800 Subject: [PATCH 2/2] Keep header anchored within the view. #002 --- MMWebViewWithSmartHeader/MMSmartHeaderWebView.m | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/MMWebViewWithSmartHeader/MMSmartHeaderWebView.m b/MMWebViewWithSmartHeader/MMSmartHeaderWebView.m index 44941fe..8e174bb 100644 --- a/MMWebViewWithSmartHeader/MMSmartHeaderWebView.m +++ b/MMWebViewWithSmartHeader/MMSmartHeaderWebView.m @@ -81,7 +81,11 @@ - (void)scrollViewDidScroll:(UIScrollView *)scrollView self.headerView.frame = headerFrame; self.scrollView.scrollIndicatorInsets = UIEdgeInsetsMake(MAX(self.headerView.frame.size.height, -scrollView.contentOffset.y), 0, 0, 0); } - + + // keep header anchored within the view + CGRect frame = self.headerView.frame; + frame.origin.x = scrollView.contentOffset.x; + self.headerView.frame = frame; } @end