Skip to content

Commit

Permalink
Just expose the inset calculation methods.
Browse files Browse the repository at this point in the history
  • Loading branch information
dblock committed May 21, 2014
1 parent 7956ac1 commit 70d042b
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 13 deletions.
1 change: 1 addition & 0 deletions TSMiniWebBrowser/TSMiniWebBrowser.h
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ typedef enum {
@property (nonatomic, assign) BOOL showReloadButton;
@property (nonatomic, assign) BOOL showActionButton;
@property (nonatomic, assign) BOOL showToolBar;
@property (nonatomic, assign) BOOL showNavigationBar;
@property (nonatomic, assign) UIBarStyle barStyle;
@property (nonatomic, assign) UIStatusBarStyle statusBarStyle;
@property (nonatomic, strong) UIColor *barTintColor;
Expand Down
22 changes: 13 additions & 9 deletions TSMiniWebBrowser/TSMiniWebBrowser.m
Original file line number Diff line number Diff line change
Expand Up @@ -252,30 +252,34 @@ - (void)initToolBar
[self.toolBar setTintColor:self.barTintColor];
}

- (void)initWebView
- (UIEdgeInsets)webViewContentInset
{
CGSize viewSize = self.view.frame.size;

CGRect webViewFrame = CGRectMake(0, 0, viewSize.width, viewSize.height);
UIEdgeInsets webViewContentInset = UIEdgeInsetsMake(kNavBarHeight, 0, self.showToolBar ? kToolBarHeight : 0, 0);
UIEdgeInsets webViewScrollIndicatorsInsets = UIEdgeInsetsMake(kNavBarHeight, 0, 0, 0);

if(self.mode == TSMiniWebBrowserModeNavigation) {
if (([[[UIDevice currentDevice] systemVersion] compare:@"7.0" options:NSNumericSearch] != NSOrderedAscending)) {
// On iOS7 the webview can be seen through the navigationbar
} else {
// On iOS below 7 we should make webView be under the navigationbar
CGFloat navBarHeight = self.navigationController.navigationBar.frame.size.height;
webViewFrame = CGRectMake(0, - navBarHeight, viewSize.width, viewSize.height+navBarHeight);
webViewContentInset = UIEdgeInsetsMake(navBarHeight, 0, self.showToolBar ? kToolBarHeight : 0, 0);
}
}
return webViewContentInset;
}

- (UIEdgeInsets)webViewScrollIndicatorsInsets
{
return UIEdgeInsetsMake(kNavBarHeight, 0, 0, 0);
}

- (void)initWebView
{
CGRect webViewFrame = CGRectMake(0, 0, CGRectGetWidth(self.view.frame), CGRectGetHeight(self.view.frame));
_webView = [[UIWebView alloc] initWithFrame:webViewFrame];
[self.view addSubview:self.webView];

self.webView.scrollView.contentInset = webViewContentInset;
self.webView.scrollView.scrollIndicatorInsets = webViewScrollIndicatorsInsets;
self.webView.scrollView.contentInset = [self webViewContentInset];
self.webView.scrollView.scrollIndicatorInsets = [self webViewScrollIndicatorsInsets];
self.webView.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;
self.webView.scalesPageToFit = YES;
self.webView.delegate = self;
Expand Down
8 changes: 4 additions & 4 deletions TSMiniWebBrowserDemo.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,6 @@

/* Begin PBXFileReference section */
1CBB0ED8C5B648EAA5C54053 /* Pods.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = Pods.xcconfig; path = Pods/Pods.xcconfig; sourceTree = "<group>"; };
3C26E12419211C1D007ECC04 /* TSMiniWebBrowserDemoTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; name = TSMiniWebBrowserDemoTests.xctest; path = "/Users/dblock/source/TSMiniWebBrowser/dblock/build/Debug-iphoneos/TSMiniWebBrowserDemoTests.xctest"; sourceTree = "<absolute>"; };
3C26E12519211C1D007ECC04 /* XCTest.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = XCTest.framework; path = Library/Frameworks/XCTest.framework; sourceTree = DEVELOPER_DIR; };
3C26E12B19211C1E007ECC04 /* TSMiniWebBrowserDemoTests-Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = "TSMiniWebBrowserDemoTests-Info.plist"; sourceTree = "<group>"; };
3C26E12D19211C1E007ECC04 /* en */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = en; path = en.lproj/InfoPlist.strings; sourceTree = "<group>"; };
Expand All @@ -64,7 +63,8 @@
3C4EF40A19216C32003FF562 /* Specta+Sleep.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "Specta+Sleep.m"; sourceTree = "<group>"; };
3C6DBF9F192B731B00197F6D /* TSMiniWebBrowser@dblock.podspec */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = "TSMiniWebBrowser@dblock.podspec"; sourceTree = "<group>"; };
3C6DBFA1192B852B00197F6D /* LICENSE */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = LICENSE; sourceTree = "<group>"; };
6F69CDB014C6339C00BB6C57 /* TSMiniWebBrowserDemo.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; name = TSMiniWebBrowserDemo.app; path = "/Users/dblock/source/TSMiniWebBrowser/dblock/build/Debug-iphoneos/TSMiniWebBrowserDemo.app"; sourceTree = "<absolute>"; };
3CBACA7B192CFCB900B6175B /* TSMiniWebBrowserDemo.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; name = TSMiniWebBrowserDemo.app; path = "/Users/dblock/source/TSMiniWebBrowser/dblock/build/Debug-iphoneos/TSMiniWebBrowserDemo.app"; sourceTree = "<absolute>"; };
3CBACA7C192CFCB900B6175B /* TSMiniWebBrowserDemoTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; name = TSMiniWebBrowserDemoTests.xctest; path = "/Users/dblock/source/TSMiniWebBrowser/dblock/build/Debug-iphoneos/TSMiniWebBrowserDemoTests.xctest"; sourceTree = "<absolute>"; };
6F69CDB414C6339C00BB6C57 /* UIKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = UIKit.framework; path = System/Library/Frameworks/UIKit.framework; sourceTree = SDKROOT; };
6F69CDB614C6339C00BB6C57 /* Foundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Foundation.framework; path = System/Library/Frameworks/Foundation.framework; sourceTree = SDKROOT; };
6F69CDB814C6339C00BB6C57 /* CoreGraphics.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreGraphics.framework; path = System/Library/Frameworks/CoreGraphics.framework; sourceTree = SDKROOT; };
Expand Down Expand Up @@ -233,7 +233,7 @@
);
name = TSMiniWebBrowserDemoTests;
productName = TSMiniWebBrowserDemoTests;
productReference = 3C26E12419211C1D007ECC04 /* TSMiniWebBrowserDemoTests.xctest */;
productReference = 3CBACA7C192CFCB900B6175B /* TSMiniWebBrowserDemoTests.xctest */;
productType = "com.apple.product-type.bundle.unit-test";
};
6F69CDAF14C6339C00BB6C57 /* TSMiniWebBrowserDemo */ = {
Expand All @@ -252,7 +252,7 @@
);
name = TSMiniWebBrowserDemo;
productName = TSMiniWebBrowserDemo;
productReference = 6F69CDB014C6339C00BB6C57 /* TSMiniWebBrowserDemo.app */;
productReference = 3CBACA7B192CFCB900B6175B /* TSMiniWebBrowserDemo.app */;
productType = "com.apple.product-type.application";
};
/* End PBXNativeTarget section */
Expand Down

0 comments on commit 70d042b

Please sign in to comment.