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 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"]]]; }