Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added loading progress with NJKWebViewProgress #85

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 2 additions & 0 deletions Demo/Podfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
platform :ios, '6.0'
pod 'SVWebViewController', :git => 'https://github.com/pilot34/SVWebViewController.git'
21 changes: 21 additions & 0 deletions Demo/Podfile.lock
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
PODS:
- NJKWebViewProgress (0.2):
- NJKWebViewProgress/Core
- NJKWebViewProgress/ProgressView
- NJKWebViewProgress/Core (0.2)
- NJKWebViewProgress/ProgressView (0.2)
- SVWebViewController (1.0):
- NJKWebViewProgress

DEPENDENCIES:
- SVWebViewController (from `https://github.com/pilot34/SVWebViewController.git`)

EXTERNAL SOURCES:
SVWebViewController:
:git: https://github.com/pilot34/SVWebViewController.git

SPEC CHECKSUMS:
NJKWebViewProgress: fd46c9489d799d97f3b09210886bf83884f6c725
SVWebViewController: d36c892657f24b9eb8ae39795e7619ce79f7fe94

COCOAPODS: 0.29.0
1,092 changes: 698 additions & 394 deletions Demo/SVWeb.xcodeproj/project.pbxproj

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions Demo/SVWeb.xcworkspace/contents.xcworkspacedata

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

41 changes: 41 additions & 0 deletions Demo/SVWeb.xcworkspace/xcshareddata/SVWeb.xccheckout
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>IDESourceControlProjectFavoriteDictionaryKey</key>
<false/>
<key>IDESourceControlProjectIdentifier</key>
<string>7FBBD4B1-99D4-49D8-AF2C-0FE239469EDA</string>
<key>IDESourceControlProjectName</key>
<string>SVWeb</string>
<key>IDESourceControlProjectOriginsDictionary</key>
<dict>
<key>096512C9-BDD9-46BE-A961-EFE6E1D08FBB</key>
<string>https://github.com/pilot34/SVWebViewController.git</string>
</dict>
<key>IDESourceControlProjectPath</key>
<string>Demo/SVWeb.xcworkspace</string>
<key>IDESourceControlProjectRelativeInstallPathDictionary</key>
<dict>
<key>096512C9-BDD9-46BE-A961-EFE6E1D08FBB</key>
<string>../..</string>
</dict>
<key>IDESourceControlProjectURL</key>
<string>https://github.com/pilot34/SVWebViewController.git</string>
<key>IDESourceControlProjectVersion</key>
<integer>110</integer>
<key>IDESourceControlProjectWCCIdentifier</key>
<string>096512C9-BDD9-46BE-A961-EFE6E1D08FBB</string>
<key>IDESourceControlProjectWCConfigurations</key>
<array>
<dict>
<key>IDESourceControlRepositoryExtensionIdentifierKey</key>
<string>public.vcs.git</string>
<key>IDESourceControlWCCIdentifierKey</key>
<string>096512C9-BDD9-46BE-A961-EFE6E1D08FBB</string>
<key>IDESourceControlWCCName</key>
<string>SVWebViewController</string>
</dict>
</array>
</dict>
</plist>
3 changes: 2 additions & 1 deletion SVWebViewController.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,10 @@ Pod::Spec.new do |s|
s.homepage = 'http://samvermette.com/173'
s.license = 'MIT'
s.author = { 'Sam Vermette' => 'hello@samvermette.com' }
s.source = { :git => 'https://github.com/samvermette/SVWebViewController.git', :tag => s.version.to_s }
s.source = { :git => 'https://github.com/pilot34/SVWebViewController.git', :tag => s.version.to_s }
s.platform = :ios, '6.0'
s.source_files = 'SVWebViewController/**/*.{h,m}'
s.resources = 'SVWebViewController/**/*.{bundle,png}'
s.requires_arc = true
s.dependency 'NJKWebViewProgress'
end
31 changes: 30 additions & 1 deletion SVWebViewController/SVWebViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,10 @@
#import "SVWebViewControllerActivityChrome.h"
#import "SVWebViewControllerActivitySafari.h"
#import "SVWebViewController.h"
#import "NJKWebViewProgressView.h"
#import "NJKWebViewProgress.h"

@interface SVWebViewController () <UIWebViewDelegate>
@interface SVWebViewController () <UIWebViewDelegate, NJKWebViewProgressDelegate>

@property (nonatomic, strong) UIBarButtonItem *backBarButtonItem;
@property (nonatomic, strong) UIBarButtonItem *forwardBarButtonItem;
Expand All @@ -21,6 +23,9 @@ @interface SVWebViewController () <UIWebViewDelegate>
@property (nonatomic, strong) UIWebView *webView;
@property (nonatomic, strong) NSURL *URL;

@property (strong, nonatomic) NJKWebViewProgressView *progressView;
@property (strong, nonatomic) NJKWebViewProgress *progressProxy;

- (id)initWithAddress:(NSString*)urlString;
- (id)initWithURL:(NSURL*)URL;
- (void)loadURL:(NSURL*)URL;
Expand Down Expand Up @@ -73,6 +78,7 @@ - (void)loadView {
- (void)viewDidLoad {
[super viewDidLoad];
[self updateToolbarItems];
[self prepareProgress];
}

- (void)viewDidUnload {
Expand All @@ -93,6 +99,8 @@ - (void)viewWillAppear:(BOOL)animated {
if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPhone) {
[self.navigationController setToolbarHidden:NO animated:animated];
}

[self.navigationController.navigationBar addSubview:self.progressView];
}

- (void)viewWillDisappear:(BOOL)animated {
Expand All @@ -101,6 +109,8 @@ - (void)viewWillDisappear:(BOOL)animated {
if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPhone) {
[self.navigationController setToolbarHidden:YES animated:animated];
}

[self.progressView removeFromSuperview];
}

- (void)viewDidDisappear:(BOOL)animated {
Expand Down Expand Up @@ -169,6 +179,20 @@ - (UIBarButtonItem *)actionBarButtonItem {
return _actionBarButtonItem;
}

#pragma mark - Progress

- (void)prepareProgress {
self.progressProxy = [[NJKWebViewProgress alloc] init];
self.webView.delegate = self.progressProxy;
self.progressProxy.webViewProxyDelegate = self;
self.progressProxy.progressDelegate = self;

CGFloat progressBarHeight = 2.5f;
CGRect navigaitonBarBounds = self.navigationController.navigationBar.bounds;
CGRect barFrame = CGRectMake(0, navigaitonBarBounds.size.height - progressBarHeight, navigaitonBarBounds.size.width, progressBarHeight);
self.progressView = [[NJKWebViewProgressView alloc] initWithFrame:barFrame];
}

#pragma mark - Toolbar

- (void)updateToolbarItems {
Expand Down Expand Up @@ -272,4 +296,9 @@ - (void)doneButtonClicked:(id)sender {
[self dismissViewControllerAnimated:YES completion:NULL];
}

#pragma mark - NJKWebViewProgressDelegate
- (void)webViewProgress:(NJKWebViewProgress *)webViewProgress updateProgress:(float)progress {
[self.progressView setProgress:progress animated:YES];
}

@end