diff --git a/TSMiniWebBrowser.podspec b/TSMiniWebBrowser.podspec new file mode 100644 index 0000000..e1242d5 --- /dev/null +++ b/TSMiniWebBrowser.podspec @@ -0,0 +1,14 @@ +Pod::Spec.new do |s| + s.name = 'TSMiniWebBrowser' + s.version = '1.0.1' + s.platform = :ios + s.license = 'MIT' + s.summary = 'An in-app web browser control for iOS apps.' + s.homepage = 'https://github.com/tonisalae/TSMiniWebBrowser' + s.author = { 'Toni Sala' => 'tonisalae@gmail.com' } + s.source = { :git => 'https://github.com/tonisalae/TSMiniWebBrowser.git', :branch => "master" } + s.source_files = 'TSMiniWebBrowser/*.{h,m}' + s.framework = 'QuartzCore' + s.requires_arc = true + s.resources = 'TSMiniWebBrowser/images/*.png', 'TSMiniWebBrowser/*.xib' +end diff --git a/TSMiniWebBrowser/TSMiniWebBrowser.m b/TSMiniWebBrowser/TSMiniWebBrowser.m index 0c8a9f5..f1d94f1 100644 --- a/TSMiniWebBrowser/TSMiniWebBrowser.m +++ b/TSMiniWebBrowser/TSMiniWebBrowser.m @@ -180,13 +180,17 @@ -(void) initWebView { if (mode == TSMiniWebBrowserModeModal) { webView = [[UIWebView alloc] initWithFrame:CGRectMake(0, kToolBarHeight, viewSize.width, viewSize.height-kToolBarHeight*2)]; } else if(mode == TSMiniWebBrowserModeNavigation) { - webView = [[UIWebView alloc] initWithFrame:CGRectMake(0, 0, viewSize.width, viewSize.height-kToolBarHeight)]; + webView = [[UIWebView alloc] initWithFrame:CGRectMake(0, 0, viewSize.width, viewSize.height)]; + bool translucentNavBar = self.navigationController.navigationBar.isTranslucent; + [[webView scrollView] setContentInset:UIEdgeInsetsMake((translucentNavBar ? 64 : 0), 0, 44, 0)]; + [[webView scrollView] setScrollIndicatorInsets:UIEdgeInsetsMake((translucentNavBar ? 64 : 0), 0, 44, 0)]; } else if(mode == TSMiniWebBrowserModeTabBar) { self.view.backgroundColor = [UIColor redColor]; webView = [[UIWebView alloc] initWithFrame:CGRectMake(0, kToolBarHeight-1, viewSize.width, viewSize.height-kToolBarHeight+1)]; } webView.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight; [self.view addSubview:webView]; + [self.view bringSubviewToFront:toolBar]; webView.scalesPageToFit = YES; @@ -215,6 +219,7 @@ - (id)initWithUrl:(NSURL*)url { forcedTitleBarText = nil; barStyle = UIBarStyleDefault; barTintColor = nil; + self.automaticallyAdjustsScrollViewInsets = NO; } return self; @@ -458,8 +463,8 @@ - (BOOL)webView:(UIWebView *)webView shouldStartLoadWithRequest:(NSURLRequest *) else { if ([[request.URL absoluteString] hasPrefix:@"http://www.youtube.com/v/"] || - [[request.URL absoluteString] hasPrefix:@"http://itunes.apple.com/"] || - [[request.URL absoluteString] hasPrefix:@"http://phobos.apple.com/"]) { + [[request.URL host] isEqualToString:@"itunes.apple.com"] || + [[request.URL host] isEqualToString:@"phobos.apple.com"]) { [[UIApplication sharedApplication] openURL:request.URL]; return NO; }