From 0313148f147a5b7b734706664c305878ed2ea796 Mon Sep 17 00:00:00 2001 From: David Muir Date: Tue, 21 Oct 2014 01:44:37 -0400 Subject: [PATCH 01/39] Updated ExampleProject to new interface. --- .../KINWebBrowserExample/KINWebBrowserExampleViewController.m | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ExampleProject/KINWebBrowserExample/KINWebBrowserExampleViewController.m b/ExampleProject/KINWebBrowserExample/KINWebBrowserExampleViewController.m index ee552ac..910f10d 100644 --- a/ExampleProject/KINWebBrowserExample/KINWebBrowserExampleViewController.m +++ b/ExampleProject/KINWebBrowserExample/KINWebBrowserExampleViewController.m @@ -99,7 +99,7 @@ - (IBAction)pushButtonPressed:(id)sender { - (IBAction)presentButtonPressed:(id)sender { UINavigationController *webBrowserNavigationController = [KINWebBrowserViewController navigationControllerWithWebBrowser]; - KINWebBrowserViewController *webBrowser = [webBrowserNavigationController rootWebBrowserViewController]; + KINWebBrowserViewController *webBrowser = [webBrowserNavigationController rootWebBrowser]; [webBrowser setDelegate:self]; webBrowser.showsURLInNavigationBar = YES; webBrowser.tintColor = [UIColor whiteColor]; From 5ba2800bd4ecdf302b32039f525db166fff96fb3 Mon Sep 17 00:00:00 2001 From: David Muir Date: Sun, 26 Oct 2014 23:02:36 -0400 Subject: [PATCH 02/39] Now supports launching external apps. For security, a UIAlertView asks the users permission before launching any external apps. --- KINWebBrowser/KINWebBrowserViewController.m | 44 +++++++++++++++++++-- 1 file changed, 40 insertions(+), 4 deletions(-) diff --git a/KINWebBrowser/KINWebBrowserViewController.m b/KINWebBrowser/KINWebBrowserViewController.m index a5e91fe..6b7cbe7 100644 --- a/KINWebBrowser/KINWebBrowserViewController.m +++ b/KINWebBrowser/KINWebBrowserViewController.m @@ -35,9 +35,9 @@ #import #import -static void *KINContext = &KINContext; +static void *KINWebBrowserContext = &KINWebBrowserContext; -@interface KINWebBrowserViewController () +@interface KINWebBrowserViewController () @property (nonatomic, assign) BOOL previousNavigationControllerToolbarHidden, previousNavigationControllerNavigationBarHidden; @property (nonatomic, strong) UIBarButtonItem *backButton, *forwardButton, *refreshButton, *stopButton, *actionButton, *fixedSeparator, *flexibleSeparator; @@ -45,6 +45,8 @@ @interface KINWebBrowserViewController () @property (nonatomic, strong) UIPopoverController *actionPopoverController; @property (nonatomic, assign) BOOL uiWebViewIsLoading; @property (nonatomic, strong) NSURL *uiWebViewCurrentURL; +@property (nonatomic, strong) NSURL *URLToLaunchWithPermission; +@property (nonatomic, strong) UIAlertView *externalAppPermissionAlertView; @end @@ -89,7 +91,6 @@ - (id)init { - (id)initWithConfiguration:(WKWebViewConfiguration *)configuration { self = [super init]; if(self) { - if([WKWebView class]) { if(configuration) { self.wkWebView = [[WKWebView alloc] initWithFrame:CGRectZero configuration:configuration]; @@ -106,6 +107,7 @@ - (id)initWithConfiguration:(WKWebViewConfiguration *)configuration { self.showsURLInNavigationBar = NO; self.showsPageTitleInNavigationBar = YES; + self.externalAppPermissionAlertView = [[UIAlertView alloc] initWithTitle:@"Leave this app?" message:@"This web page is trying to open an outside app. Do you want to open it?" delegate:self cancelButtonTitle:@"Cancel" otherButtonTitles:@"Open App", nil]; } return self; } @@ -127,7 +129,7 @@ - (void)viewDidLoad { [self.wkWebView.scrollView setAlwaysBounceVertical:YES]; [self.view addSubview:self.wkWebView]; - [self.wkWebView addObserver:self forKeyPath:NSStringFromSelector(@selector(estimatedProgress)) options:0 context:KINContext]; + [self.wkWebView addObserver:self forKeyPath:NSStringFromSelector(@selector(estimatedProgress)) options:0 context:KINWebBrowserContext]; } else if(self.uiWebView) { [self.uiWebView setFrame:self.view.bounds]; @@ -290,6 +292,29 @@ - (void)webView:(WKWebView *)webView didFailNavigation:(WKNavigation *)navigatio } } +- (void)webView:(WKWebView *)webView decidePolicyForNavigationAction:(WKNavigationAction *)navigationAction decisionHandler:(void (^)(WKNavigationActionPolicy))decisionHandler { + if(webView == self.wkWebView) { + + NSSet *validSchemes = [NSSet setWithArray:@[@"http", @"https"]]; + + NSURL *URL = navigationAction.request.URL; + if([validSchemes containsObject:URL.scheme]) { + if(!navigationAction.targetFrame) { + [self loadURL:URL]; + decisionHandler(WKNavigationActionPolicyCancel); + return; + } + } + else if([[UIApplication sharedApplication] canOpenURL:URL]) { + self.URLToLaunchWithPermission = URL; + [self.externalAppPermissionAlertView show]; + decisionHandler(WKNavigationActionPolicyCancel); + return; + } + } + decisionHandler(WKNavigationActionPolicyAllow); +} + #pragma mark - Toolbar State - (void)updateToolbarState { @@ -490,6 +515,17 @@ - (void)fakeProgressTimerDidFire:(id)sender { } } +#pragma mark - UIAlertViewDelegate + +- (void)alertView:(UIAlertView *)alertView didDismissWithButtonIndex:(NSInteger)buttonIndex { + if(alertView == self.externalAppPermissionAlertView) { + if(buttonIndex != alertView.cancelButtonIndex) { + [[UIApplication sharedApplication] openURL:self.URLToLaunchWithPermission]; + } + self.URLToLaunchWithPermission = nil; + } +} + #pragma mark - Dismiss - (void)dismissAnimated:(BOOL)animated { From 95c9ffcb3c9e6a9a86f78f8ae1d4af682edf34a7 Mon Sep 17 00:00:00 2001 From: ShinyaSakemoto Date: Tue, 18 Nov 2014 15:04:11 +0900 Subject: [PATCH 03/39] add page title in share text --- KINWebBrowser/KINWebBrowserViewController.m | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/KINWebBrowser/KINWebBrowserViewController.m b/KINWebBrowser/KINWebBrowserViewController.m index a5e91fe..ee434f9 100644 --- a/KINWebBrowser/KINWebBrowserViewController.m +++ b/KINWebBrowser/KINWebBrowserViewController.m @@ -407,16 +407,19 @@ - (void)stopButtonPressed:(id)sender { - (void)actionButtonPressed:(id)sender { NSURL *URLForActivityItem; + NSString *URLtitle; if(self.wkWebView) { URLForActivityItem = self.wkWebView.URL; + URLTitle = self.wkWebView.title; } else if(self.uiWebView) { URLForActivityItem = self.uiWebView.request.URL; + URLTitle = [self.uiWebView stringByEvaluatingJavaScriptFromString:@"document.title"]; } dispatch_async(dispatch_get_main_queue(), ^{ TUSafariActivity *safariActivity = [[TUSafariActivity alloc] init]; ARChromeActivity *chromeActivity = [[ARChromeActivity alloc] init]; - UIActivityViewController *controller = [[UIActivityViewController alloc] initWithActivityItems:@[URLForActivityItem] applicationActivities:@[safariActivity, chromeActivity]]; + UIActivityViewController *controller = [[UIActivityViewController alloc] initWithActivityItems:@[URLForActivityItem, URLTitle] applicationActivities:@[safariActivity, chromeActivity]]; if(UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad) { if(self.actionPopoverController) { [self.actionPopoverController dismissPopoverAnimated:YES]; From cd3126d6faf2871faa14c64163356bab44b7099e Mon Sep 17 00:00:00 2001 From: Alessandro Segala Date: Fri, 30 Jan 2015 17:03:38 -0500 Subject: [PATCH 04/39] Added a delegate method for understanding when the browser is about to close --- .../KINWebBrowserExampleViewController.m | 5 +++++ KINWebBrowser/KINWebBrowserViewController.h | 1 + KINWebBrowser/KINWebBrowserViewController.m | 3 +++ 3 files changed, 9 insertions(+) diff --git a/ExampleProject/KINWebBrowserExample/KINWebBrowserExampleViewController.m b/ExampleProject/KINWebBrowserExample/KINWebBrowserExampleViewController.m index 910f10d..cf352d1 100644 --- a/ExampleProject/KINWebBrowserExample/KINWebBrowserExampleViewController.m +++ b/ExampleProject/KINWebBrowserExample/KINWebBrowserExampleViewController.m @@ -87,6 +87,11 @@ - (void)webBrowser:(KINWebBrowserViewController *)webBrowser didFailToLoadURL:(N NSLog(@"Failed To Load URL : %@ With Error: %@", URL, error); } +- (void)webBrowserViewControllerWillDismiss:(KINWebBrowserViewController*)viewController { + NSLog(@"View Controller will dismiss: %@", viewController); + +} + #pragma mark - IBActions diff --git a/KINWebBrowser/KINWebBrowserViewController.h b/KINWebBrowser/KINWebBrowserViewController.h index fe1af16..562144e 100644 --- a/KINWebBrowser/KINWebBrowserViewController.h +++ b/KINWebBrowser/KINWebBrowserViewController.h @@ -54,6 +54,7 @@ - (void)webBrowser:(KINWebBrowserViewController *)webBrowser didStartLoadingURL:(NSURL *)URL; - (void)webBrowser:(KINWebBrowserViewController *)webBrowser didFinishLoadingURL:(NSURL *)URL; - (void)webBrowser:(KINWebBrowserViewController *)webBrowser didFailToLoadURL:(NSURL *)URL error:(NSError *)error; +- (void)webBrowserViewControllerWillDismiss:(KINWebBrowserViewController*)viewController; @end diff --git a/KINWebBrowser/KINWebBrowserViewController.m b/KINWebBrowser/KINWebBrowserViewController.m index a5e91fe..4d0e445 100644 --- a/KINWebBrowser/KINWebBrowserViewController.m +++ b/KINWebBrowser/KINWebBrowserViewController.m @@ -493,6 +493,9 @@ - (void)fakeProgressTimerDidFire:(id)sender { #pragma mark - Dismiss - (void)dismissAnimated:(BOOL)animated { + if([self.delegate respondsToSelector:@selector(webBrowserViewControllerWillDismiss:)]) { + [self.delegate webBrowserViewControllerWillDismiss:self]; + } [self.navigationController dismissViewControllerAnimated:animated completion:nil]; } From 6d49d3bc61cc52ab1f9c8abe46b2e8059dbbc48a Mon Sep 17 00:00:00 2001 From: front9tech Date: Sun, 29 Mar 2015 13:36:42 -0400 Subject: [PATCH 05/39] Adding custom activities array --- KINWebBrowser/KINWebBrowserViewController.h | 3 +++ 1 file changed, 3 insertions(+) diff --git a/KINWebBrowser/KINWebBrowserViewController.h b/KINWebBrowser/KINWebBrowserViewController.h index fe1af16..d4c9bb9 100644 --- a/KINWebBrowser/KINWebBrowserViewController.h +++ b/KINWebBrowser/KINWebBrowserViewController.h @@ -111,6 +111,9 @@ @property (nonatomic, assign) BOOL showsURLInNavigationBar; @property (nonatomic, assign) BOOL showsPageTitleInNavigationBar; +//Allow for custom activities in the browser by populating this optional array +@property (nonatomic, strong) NSArray *customActivities; + #pragma mark - Public Interface // Load a NSURL to webView From ad02faf2342eb2b26a7a7ae9b8c07e16ff1d70ba Mon Sep 17 00:00:00 2001 From: front9tech Date: Sun, 29 Mar 2015 13:42:04 -0400 Subject: [PATCH 06/39] Adding custom activities array --- KINWebBrowser/KINWebBrowserViewController.m | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/KINWebBrowser/KINWebBrowserViewController.m b/KINWebBrowser/KINWebBrowserViewController.m index a5e91fe..db255c6 100644 --- a/KINWebBrowser/KINWebBrowserViewController.m +++ b/KINWebBrowser/KINWebBrowserViewController.m @@ -416,7 +416,16 @@ - (void)actionButtonPressed:(id)sender { dispatch_async(dispatch_get_main_queue(), ^{ TUSafariActivity *safariActivity = [[TUSafariActivity alloc] init]; ARChromeActivity *chromeActivity = [[ARChromeActivity alloc] init]; - UIActivityViewController *controller = [[UIActivityViewController alloc] initWithActivityItems:@[URLForActivityItem] applicationActivities:@[safariActivity, chromeActivity]]; + + //Allow for custom activities in the browser by populating this optional array + NSMutableArray *applicationActivities = [[NSMutableArray alloc] init]; + [applicationActivities addObject:safariActivity]; + [applicationActivities addObject:chromeActivity]; + if(self.customActivities != nil) { + [applicationActivities addObjectsFromArray:self.customActivities]; + } + + UIActivityViewController *controller = [[UIActivityViewController alloc] initWithActivityItems:@[URLForActivityItem] applicationActivities:applicationActivities]; if(UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad) { if(self.actionPopoverController) { [self.actionPopoverController dismissPopoverAnimated:YES]; From 551a43f948efd4c929d337aa070e9a003d5a7d93 Mon Sep 17 00:00:00 2001 From: David Muir Date: Sun, 26 Oct 2014 23:02:36 -0400 Subject: [PATCH 07/39] Now supports launching external apps. For security, a UIAlertView asks the users permission before launching any external apps. --- .../KINWebBrowserExampleViewController.m | 2 +- KINWebBrowser/KINWebBrowserViewController.m | 79 ++++++++++++++++--- 2 files changed, 68 insertions(+), 13 deletions(-) diff --git a/ExampleProject/KINWebBrowserExample/KINWebBrowserExampleViewController.m b/ExampleProject/KINWebBrowserExample/KINWebBrowserExampleViewController.m index 910f10d..b4ef8eb 100644 --- a/ExampleProject/KINWebBrowserExample/KINWebBrowserExampleViewController.m +++ b/ExampleProject/KINWebBrowserExample/KINWebBrowserExampleViewController.m @@ -38,7 +38,7 @@ @interface KINWebBrowserExampleViewController () @end -static NSString *const defaultAddress = @"http://www.apple.com/"; +static NSString *const defaultAddress = @"https://www.apple.com"; @implementation KINWebBrowserExampleViewController diff --git a/KINWebBrowser/KINWebBrowserViewController.m b/KINWebBrowser/KINWebBrowserViewController.m index a5e91fe..127b28e 100644 --- a/KINWebBrowser/KINWebBrowserViewController.m +++ b/KINWebBrowser/KINWebBrowserViewController.m @@ -35,9 +35,9 @@ #import #import -static void *KINContext = &KINContext; +static void *KINWebBrowserContext = &KINWebBrowserContext; -@interface KINWebBrowserViewController () +@interface KINWebBrowserViewController () @property (nonatomic, assign) BOOL previousNavigationControllerToolbarHidden, previousNavigationControllerNavigationBarHidden; @property (nonatomic, strong) UIBarButtonItem *backButton, *forwardButton, *refreshButton, *stopButton, *actionButton, *fixedSeparator, *flexibleSeparator; @@ -45,6 +45,8 @@ @interface KINWebBrowserViewController () @property (nonatomic, strong) UIPopoverController *actionPopoverController; @property (nonatomic, assign) BOOL uiWebViewIsLoading; @property (nonatomic, strong) NSURL *uiWebViewCurrentURL; +@property (nonatomic, strong) NSURL *URLToLaunchWithPermission; +@property (nonatomic, strong) UIAlertView *externalAppPermissionAlertView; @end @@ -89,7 +91,6 @@ - (id)init { - (id)initWithConfiguration:(WKWebViewConfiguration *)configuration { self = [super init]; if(self) { - if([WKWebView class]) { if(configuration) { self.wkWebView = [[WKWebView alloc] initWithFrame:CGRectZero configuration:configuration]; @@ -106,6 +107,7 @@ - (id)initWithConfiguration:(WKWebViewConfiguration *)configuration { self.showsURLInNavigationBar = NO; self.showsPageTitleInNavigationBar = YES; + self.externalAppPermissionAlertView = [[UIAlertView alloc] initWithTitle:@"Leave this app?" message:@"This web page is trying to open an outside app. Are you sure you want to open it?" delegate:self cancelButtonTitle:@"Cancel" otherButtonTitles:@"Open App", nil]; } return self; } @@ -127,7 +129,7 @@ - (void)viewDidLoad { [self.wkWebView.scrollView setAlwaysBounceVertical:YES]; [self.view addSubview:self.wkWebView]; - [self.wkWebView addObserver:self forKeyPath:NSStringFromSelector(@selector(estimatedProgress)) options:0 context:KINContext]; + [self.wkWebView addObserver:self forKeyPath:NSStringFromSelector(@selector(estimatedProgress)) options:0 context:KINWebBrowserContext]; } else if(self.uiWebView) { [self.uiWebView setFrame:self.view.bounds]; @@ -208,17 +210,25 @@ - (void)setActionButtonHidden:(BOOL)actionButtonHidden { - (BOOL)webView:(UIWebView *)webView shouldStartLoadWithRequest:(NSURLRequest *)request navigationType:(UIWebViewNavigationType)navigationType { if(webView == self.uiWebView) { - self.uiWebViewCurrentURL = request.URL; - self.uiWebViewIsLoading = YES; - [self updateToolbarState]; - [self fakeProgressViewStartLoading]; - - if([self.delegate respondsToSelector:@selector(webBrowser:didStartLoadingURL:)]) { - [self.delegate webBrowser:self didStartLoadingURL:request.URL]; + if(![self externalAppRequiredToOpenURL:request.URL]) { + self.uiWebViewCurrentURL = request.URL; + self.uiWebViewIsLoading = YES; + [self updateToolbarState]; + + [self fakeProgressViewStartLoading]; + + if([self.delegate respondsToSelector:@selector(webBrowser:didStartLoadingURL:)]) { + [self.delegate webBrowser:self didStartLoadingURL:request.URL]; + } + return YES; + } + else { + [self launchExternalAppWithURL:request.URL]; + return NO; } } - return YES; + return NO; } - (void)webViewDidFinishLoad:(UIWebView *)webView { @@ -290,6 +300,28 @@ - (void)webView:(WKWebView *)webView didFailNavigation:(WKNavigation *)navigatio } } +- (void)webView:(WKWebView *)webView decidePolicyForNavigationAction:(WKNavigationAction *)navigationAction decisionHandler:(void (^)(WKNavigationActionPolicy))decisionHandler { + if(webView == self.wkWebView) { + + + + NSURL *URL = navigationAction.request.URL; + if(![self externalAppRequiredToOpenURL:URL]) { + if(!navigationAction.targetFrame) { + [self loadURL:URL]; + decisionHandler(WKNavigationActionPolicyCancel); + return; + } + } + else if([[UIApplication sharedApplication] canOpenURL:URL]) { + [self launchExternalAppWithURL:URL]; + decisionHandler(WKNavigationActionPolicyCancel); + return; + } + } + decisionHandler(WKNavigationActionPolicyAllow); +} + #pragma mark - Toolbar State - (void)updateToolbarState { @@ -490,6 +522,29 @@ - (void)fakeProgressTimerDidFire:(id)sender { } } +#pragma mark - External App Support + +- (BOOL)externalAppRequiredToOpenURL:(NSURL *)URL { + NSSet *validSchemes = [NSSet setWithArray:@[@"http", @"https"]]; + return ![validSchemes containsObject:URL.scheme]; +} + +- (void)launchExternalAppWithURL:(NSURL *)URL { + self.URLToLaunchWithPermission = URL; + [self.externalAppPermissionAlertView show]; +} + +#pragma mark - UIAlertViewDelegate + +- (void)alertView:(UIAlertView *)alertView didDismissWithButtonIndex:(NSInteger)buttonIndex { + if(alertView == self.externalAppPermissionAlertView) { + if(buttonIndex != alertView.cancelButtonIndex) { + [[UIApplication sharedApplication] openURL:self.URLToLaunchWithPermission]; + } + self.URLToLaunchWithPermission = nil; + } +} + #pragma mark - Dismiss - (void)dismissAnimated:(BOOL)animated { From 5e04df3a16a08d1bcaa64ce3da26edccebd71be3 Mon Sep 17 00:00:00 2001 From: David Muir Date: Sun, 10 May 2015 00:35:18 -0400 Subject: [PATCH 08/39] Updated podspec to 1.0.3 --- KINWebBrowser.podspec | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/KINWebBrowser.podspec b/KINWebBrowser.podspec index 76d76da..c542888 100644 --- a/KINWebBrowser.podspec +++ b/KINWebBrowser.podspec @@ -3,7 +3,7 @@ Pod::Spec.new do |s| s.name = "KINWebBrowser" - s.version = "1.0.2" + s.version = "1.0.3" s.summary = "A web browser module for your apps." s.description = <<-DESC KINWebBrowser is a web browser module for your apps. Powered by WKWebView on iOS 8. Backwards compatible with iOS 7 using UIWebView. KINWebBrowser offers the simplest way to add a web browser to your apps. From e9e583239317ef414fd32327a06c664500cff229 Mon Sep 17 00:00:00 2001 From: David Muir Date: Sun, 10 May 2015 01:05:32 -0400 Subject: [PATCH 09/39] Fixed issue where tintColor and barTintColor might have no effect. --- KINWebBrowser/KINWebBrowserViewController.m | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/KINWebBrowser/KINWebBrowserViewController.m b/KINWebBrowser/KINWebBrowserViewController.m index c61026a..8660b1e 100644 --- a/KINWebBrowser/KINWebBrowserViewController.m +++ b/KINWebBrowser/KINWebBrowserViewController.m @@ -32,8 +32,8 @@ #import "KINWebBrowserViewController.h" -#import -#import +#import "TUSafariActivity.h" +#import "ARChromeActivity.h" static void *KINWebBrowserContext = &KINWebBrowserContext; @@ -108,7 +108,7 @@ - (id)initWithConfiguration:(WKWebViewConfiguration *)configuration { self.showsPageTitleInNavigationBar = YES; self.externalAppPermissionAlertView = [[UIAlertView alloc] initWithTitle:@"Leave this app?" message:@"This web page is trying to open an outside app. Are you sure you want to open it?" delegate:self cancelButtonTitle:@"Cancel" otherButtonTitles:@"Open App", nil]; - + } return self; } @@ -374,6 +374,11 @@ - (void)updateToolbarState { } [self setToolbarItems:barButtonItems animated:YES]; + + self.tintColor = self.tintColor; + self.barTintColor = self.barTintColor; + + } - (void)setupToolbarItems { From 2a0a9e7e70fa2bb071413e2564eb2f13be4b74bc Mon Sep 17 00:00:00 2001 From: David Muir Date: Sun, 10 May 2015 01:56:05 -0400 Subject: [PATCH 10/39] Updated podspec to 1.2.1 --- KINWebBrowser.podspec | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/KINWebBrowser.podspec b/KINWebBrowser.podspec index 519351b..1768969 100644 --- a/KINWebBrowser.podspec +++ b/KINWebBrowser.podspec @@ -3,7 +3,7 @@ Pod::Spec.new do |s| s.name = "KINWebBrowser" - s.version = "1.2.0" + s.version = "1.2.1" s.summary = "A web browser module for your apps." s.description = <<-DESC From 54fac36a77bc914a08d7e7c8f6e50a3e057f319c Mon Sep 17 00:00:00 2001 From: David Muir Date: Sun, 10 May 2015 01:56:05 -0400 Subject: [PATCH 11/39] Updated podspec to 1.2.1 --- ExampleProject/Podfile | 2 +- KINWebBrowser.podspec | 2 +- KINWebBrowser/KINWebBrowserViewController.m | 10 +++++----- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/ExampleProject/Podfile b/ExampleProject/Podfile index 8b6339e..0b4470c 100644 --- a/ExampleProject/Podfile +++ b/ExampleProject/Podfile @@ -3,4 +3,4 @@ source 'https://github.com/CocoaPods/Specs.git' xcodeproj 'KINWebBrowserExample.xcodeproj' platform :ios, :deployment_target => '7.0' -pod 'KINWebBrowser', '~> 1.1' +pod 'KINWebBrowser', '~> 1.2' diff --git a/KINWebBrowser.podspec b/KINWebBrowser.podspec index 519351b..1768969 100644 --- a/KINWebBrowser.podspec +++ b/KINWebBrowser.podspec @@ -3,7 +3,7 @@ Pod::Spec.new do |s| s.name = "KINWebBrowser" - s.version = "1.2.0" + s.version = "1.2.1" s.summary = "A web browser module for your apps." s.description = <<-DESC diff --git a/KINWebBrowser/KINWebBrowserViewController.m b/KINWebBrowser/KINWebBrowserViewController.m index 8122f2d..f63345e 100644 --- a/KINWebBrowser/KINWebBrowserViewController.m +++ b/KINWebBrowser/KINWebBrowserViewController.m @@ -443,7 +443,7 @@ - (void)stopButtonPressed:(id)sender { - (void)actionButtonPressed:(id)sender { NSURL *URLForActivityItem; - NSString *URLtitle; + NSString *URLTitle; if(self.wkWebView) { URLForActivityItem = self.wkWebView.URL; URLTitle = self.wkWebView.title; @@ -564,9 +564,9 @@ - (void)alertView:(UIAlertView *)alertView didDismissWithButtonIndex:(NSInteger) #pragma mark - Dismiss - (void)dismissAnimated:(BOOL)animated { - if([self.delegate respondsToSelector:@selector(webBrowserViewControllerWillDismiss:)]) { - [self.delegate webBrowserViewControllerWillDismiss:self]; - } + if([self.delegate respondsToSelector:@selector(webBrowserViewControllerWillDismiss:)]) { + [self.delegate webBrowserViewControllerWillDismiss:self]; + } [self.navigationController dismissViewControllerAnimated:animated completion:nil]; } @@ -602,4 +602,4 @@ - (KINWebBrowserViewController *)rootWebBrowser { return (KINWebBrowserViewController *)rootViewController; } -@end +@end \ No newline at end of file From ceff0633b874c5ca2062ae07d50dc2b862de817f Mon Sep 17 00:00:00 2001 From: David Muir Date: Sun, 10 May 2015 02:12:39 -0400 Subject: [PATCH 12/39] Updated podspec to 1.2.2 --- KINWebBrowser.podspec | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/KINWebBrowser.podspec b/KINWebBrowser.podspec index 1768969..d5a8d26 100644 --- a/KINWebBrowser.podspec +++ b/KINWebBrowser.podspec @@ -2,9 +2,7 @@ Pod::Spec.new do |s| s.name = "KINWebBrowser" - - s.version = "1.2.1" - + s.version = "1.2.2" s.summary = "A web browser module for your apps." s.description = <<-DESC KINWebBrowser is a web browser module for your apps. Powered by WKWebView on iOS 8. Backwards compatible with iOS 7 using UIWebView. KINWebBrowser offers the simplest way to add a web browser to your apps. From 2032a047c121d3f43110ac71c449c3d8958b21f0 Mon Sep 17 00:00:00 2001 From: David Muir Date: Sun, 10 May 2015 02:16:56 -0400 Subject: [PATCH 13/39] Changed initialization to better support subclassing at suggestion of @colinta --- KINWebBrowser/KINWebBrowserViewController.m | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/KINWebBrowser/KINWebBrowserViewController.m b/KINWebBrowser/KINWebBrowserViewController.m index f63345e..937e4cd 100644 --- a/KINWebBrowser/KINWebBrowserViewController.m +++ b/KINWebBrowser/KINWebBrowserViewController.m @@ -60,17 +60,17 @@ + (KINWebBrowserViewController *)webBrowser { } + (KINWebBrowserViewController *)webBrowserWithConfiguration:(WKWebViewConfiguration *)configuration { - KINWebBrowserViewController *webBrowserViewController = [[KINWebBrowserViewController alloc] initWithConfiguration:configuration]; + KINWebBrowserViewController *webBrowserViewController = [[self alloc] initWithConfiguration:configuration]; return webBrowserViewController; } + (UINavigationController *)navigationControllerWithWebBrowser { - KINWebBrowserViewController *webBrowserViewController = [[KINWebBrowserViewController alloc] initWithConfiguration:nil]; + KINWebBrowserViewController *webBrowserViewController = [[self alloc] initWithConfiguration:nil]; return [KINWebBrowserViewController navigationControllerWithBrowser:webBrowserViewController]; } + (UINavigationController *)navigationControllerWithWebBrowserWithConfiguration:(WKWebViewConfiguration *)configuration { - KINWebBrowserViewController *webBrowserViewController = [[KINWebBrowserViewController alloc] initWithConfiguration:configuration]; + KINWebBrowserViewController *webBrowserViewController = [[self alloc] initWithConfiguration:configuration]; return [KINWebBrowserViewController navigationControllerWithBrowser:webBrowserViewController]; } From 2386cbfe1df917822d670e1aa6f08dc8529b6e45 Mon Sep 17 00:00:00 2001 From: David Muir Date: Sun, 10 May 2015 02:17:28 -0400 Subject: [PATCH 14/39] Updated podspec to 1.2.3 --- KINWebBrowser.podspec | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/KINWebBrowser.podspec b/KINWebBrowser.podspec index d5a8d26..80f565b 100644 --- a/KINWebBrowser.podspec +++ b/KINWebBrowser.podspec @@ -2,7 +2,7 @@ Pod::Spec.new do |s| s.name = "KINWebBrowser" - s.version = "1.2.2" + s.version = "1.2.3" s.summary = "A web browser module for your apps." s.description = <<-DESC KINWebBrowser is a web browser module for your apps. Powered by WKWebView on iOS 8. Backwards compatible with iOS 7 using UIWebView. KINWebBrowser offers the simplest way to add a web browser to your apps. From fb5fd16d039583a39d85a5833a80c23e48ed825f Mon Sep 17 00:00:00 2001 From: David Muir Date: Sun, 17 May 2015 01:22:28 -0400 Subject: [PATCH 15/39] Replaced deprecated interface idiom macro with modern code. --- ExampleProject/Podfile | 2 +- KINWebBrowser.podspec | 2 +- KINWebBrowser/KINWebBrowserViewController.m | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/ExampleProject/Podfile b/ExampleProject/Podfile index 0b4470c..08535b0 100644 --- a/ExampleProject/Podfile +++ b/ExampleProject/Podfile @@ -3,4 +3,4 @@ source 'https://github.com/CocoaPods/Specs.git' xcodeproj 'KINWebBrowserExample.xcodeproj' platform :ios, :deployment_target => '7.0' -pod 'KINWebBrowser', '~> 1.2' +pod 'KINWebBrowser' diff --git a/KINWebBrowser.podspec b/KINWebBrowser.podspec index 80f565b..7a05d16 100644 --- a/KINWebBrowser.podspec +++ b/KINWebBrowser.podspec @@ -2,7 +2,7 @@ Pod::Spec.new do |s| s.name = "KINWebBrowser" - s.version = "1.2.3" + s.version = "1.2.4" s.summary = "A web browser module for your apps." s.description = <<-DESC KINWebBrowser is a web browser module for your apps. Powered by WKWebView on iOS 8. Backwards compatible with iOS 7 using UIWebView. KINWebBrowser offers the simplest way to add a web browser to your apps. diff --git a/KINWebBrowser/KINWebBrowserViewController.m b/KINWebBrowser/KINWebBrowserViewController.m index 937e4cd..3854cf3 100644 --- a/KINWebBrowser/KINWebBrowserViewController.m +++ b/KINWebBrowser/KINWebBrowserViewController.m @@ -465,7 +465,7 @@ - (void)actionButtonPressed:(id)sender { UIActivityViewController *controller = [[UIActivityViewController alloc] initWithActivityItems:@[URLForActivityItem] applicationActivities:activities]; - if(UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad) { + if([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPad) { if(self.actionPopoverController) { [self.actionPopoverController dismissPopoverAnimated:YES]; } From 0014c1f40191ba29680897e630e671644f35068e Mon Sep 17 00:00:00 2001 From: David Muir Date: Sun, 17 May 2015 01:22:28 -0400 Subject: [PATCH 16/39] Replaced deprecated interface idiom macro with modern code. --- ExampleProject/Podfile | 2 +- KINWebBrowser.podspec | 2 +- KINWebBrowser/KINWebBrowserViewController.m | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/ExampleProject/Podfile b/ExampleProject/Podfile index 0b4470c..08535b0 100644 --- a/ExampleProject/Podfile +++ b/ExampleProject/Podfile @@ -3,4 +3,4 @@ source 'https://github.com/CocoaPods/Specs.git' xcodeproj 'KINWebBrowserExample.xcodeproj' platform :ios, :deployment_target => '7.0' -pod 'KINWebBrowser', '~> 1.2' +pod 'KINWebBrowser' diff --git a/KINWebBrowser.podspec b/KINWebBrowser.podspec index 80f565b..7a05d16 100644 --- a/KINWebBrowser.podspec +++ b/KINWebBrowser.podspec @@ -2,7 +2,7 @@ Pod::Spec.new do |s| s.name = "KINWebBrowser" - s.version = "1.2.3" + s.version = "1.2.4" s.summary = "A web browser module for your apps." s.description = <<-DESC KINWebBrowser is a web browser module for your apps. Powered by WKWebView on iOS 8. Backwards compatible with iOS 7 using UIWebView. KINWebBrowser offers the simplest way to add a web browser to your apps. diff --git a/KINWebBrowser/KINWebBrowserViewController.m b/KINWebBrowser/KINWebBrowserViewController.m index 937e4cd..525c5ae 100644 --- a/KINWebBrowser/KINWebBrowserViewController.m +++ b/KINWebBrowser/KINWebBrowserViewController.m @@ -465,7 +465,7 @@ - (void)actionButtonPressed:(id)sender { UIActivityViewController *controller = [[UIActivityViewController alloc] initWithActivityItems:@[URLForActivityItem] applicationActivities:activities]; - if(UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad) { + if([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPad) { if(self.actionPopoverController) { [self.actionPopoverController dismissPopoverAnimated:YES]; } @@ -602,4 +602,4 @@ - (KINWebBrowserViewController *)rootWebBrowser { return (KINWebBrowserViewController *)rootViewController; } -@end \ No newline at end of file +@end From 08951f909a0c54a3269529238d53669cb37fbfc0 Mon Sep 17 00:00:00 2001 From: Thomas Kollbach Date: Fri, 28 Aug 2015 23:45:11 +0200 Subject: [PATCH 17/39] update dependency to support frameworks --- KINWebBrowser.podspec | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/KINWebBrowser.podspec b/KINWebBrowser.podspec index 7a05d16..a1e1876 100644 --- a/KINWebBrowser.podspec +++ b/KINWebBrowser.podspec @@ -19,7 +19,7 @@ Pod::Spec.new do |s| s.weak_framework = 'WebKit' - s.dependency 'TUSafariActivity', '1.0.2' + s.dependency 'TUSafariActivity', '1.0.4' s.dependency 'ARChromeActivity', '1.0.2' end \ No newline at end of file From 6e130cf4d8b4046c860281d11937548136ed4930 Mon Sep 17 00:00:00 2001 From: Thomas Kollbach Date: Sun, 30 Aug 2015 16:53:20 +0200 Subject: [PATCH 18/39] take images out of bundles --- KINWebBrowser/KINWebBrowserViewController.m | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/KINWebBrowser/KINWebBrowserViewController.m b/KINWebBrowser/KINWebBrowserViewController.m index 525c5ae..7bc7a21 100644 --- a/KINWebBrowser/KINWebBrowserViewController.m +++ b/KINWebBrowser/KINWebBrowserViewController.m @@ -382,10 +382,16 @@ - (void)updateToolbarState { } - (void)setupToolbarItems { + NSBundle *bundle = [NSBundle bundleForClass:[self class]]; + self.refreshButton = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemRefresh target:self action:@selector(refreshButtonPressed:)]; self.stopButton = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemStop target:self action:@selector(stopButtonPressed:)]; - self.backButton = [[UIBarButtonItem alloc] initWithImage:[UIImage imageNamed:@"backbutton"] style:UIBarButtonItemStylePlain target:self action:@selector(backButtonPressed:)]; - self.forwardButton = [[UIBarButtonItem alloc] initWithImage:[UIImage imageNamed:@"forwardbutton"] style:UIBarButtonItemStylePlain target:self action:@selector(forwardButtonPressed:)]; + + UIImage *backbuttonImage = [UIImage imageWithContentsOfFile: [bundle pathForResource:@"backbutton" ofType:@"png"]]; + self.backButton = [[UIBarButtonItem alloc] initWithImage:backbuttonImage style:UIBarButtonItemStylePlain target:self action:@selector(backButtonPressed:)]; + + UIImage *forwardbuttonImage = [UIImage imageWithContentsOfFile: [bundle pathForResource:@"forwardbutton" ofType:@"png"]]; + self.forwardButton = [[UIBarButtonItem alloc] initWithImage:forwardbuttonImage style:UIBarButtonItemStylePlain target:self action:@selector(forwardButtonPressed:)]; self.actionButton = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemAction target:self action:@selector(actionButtonPressed:)]; self.fixedSeparator = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemFixedSpace target:nil action:nil]; self.fixedSeparator.width = 50.0f; From 304ee69e85beea552f21f48a469d93027a4c4f75 Mon Sep 17 00:00:00 2001 From: David Muir Date: Thu, 3 Sep 2015 21:09:59 -0400 Subject: [PATCH 19/39] Added ability to load HTML string. --- ExampleProject/Podfile | 2 +- KINWebBrowser/KINWebBrowserViewController.h | 5 +++++ KINWebBrowser/KINWebBrowserViewController.m | 11 ++++++++++- 3 files changed, 16 insertions(+), 2 deletions(-) diff --git a/ExampleProject/Podfile b/ExampleProject/Podfile index 08535b0..f6e689e 100644 --- a/ExampleProject/Podfile +++ b/ExampleProject/Podfile @@ -3,4 +3,4 @@ source 'https://github.com/CocoaPods/Specs.git' xcodeproj 'KINWebBrowserExample.xcodeproj' platform :ios, :deployment_target => '7.0' -pod 'KINWebBrowser' +pod 'KINWebBrowser', :head diff --git a/KINWebBrowser/KINWebBrowserViewController.h b/KINWebBrowser/KINWebBrowserViewController.h index 77099ef..70f1f6c 100644 --- a/KINWebBrowser/KINWebBrowserViewController.h +++ b/KINWebBrowser/KINWebBrowserViewController.h @@ -125,5 +125,10 @@ // Can be called any time after initialization - (void)loadURLString:(NSString *)URLString; + +// Loads an string containing HTML to webView +// Can be called any time after initialization +- (void)loadHTMLString:(NSString *)HTMLString; + @end diff --git a/KINWebBrowser/KINWebBrowserViewController.m b/KINWebBrowser/KINWebBrowserViewController.m index 7bc7a21..4a563c9 100644 --- a/KINWebBrowser/KINWebBrowserViewController.m +++ b/KINWebBrowser/KINWebBrowserViewController.m @@ -188,6 +188,15 @@ - (void)loadURLString:(NSString *)URLString { [self loadURL:URL]; } +- (void)loadHTMLString:(NSString *)HTMLString { + if(self.wkWebView) { + [self.wkWebView loadHTMLString:HTMLString baseURL:nil]; + } + else if(self.uiWebView) { + [self.uiWebView loadHTMLString:HTMLString baseURL:nil]; + } +} + - (void)setTintColor:(UIColor *)tintColor { _tintColor = tintColor; [self.progressView setTintColor:tintColor]; @@ -389,7 +398,7 @@ - (void)setupToolbarItems { UIImage *backbuttonImage = [UIImage imageWithContentsOfFile: [bundle pathForResource:@"backbutton" ofType:@"png"]]; self.backButton = [[UIBarButtonItem alloc] initWithImage:backbuttonImage style:UIBarButtonItemStylePlain target:self action:@selector(backButtonPressed:)]; - + UIImage *forwardbuttonImage = [UIImage imageWithContentsOfFile: [bundle pathForResource:@"forwardbutton" ofType:@"png"]]; self.forwardButton = [[UIBarButtonItem alloc] initWithImage:forwardbuttonImage style:UIBarButtonItemStylePlain target:self action:@selector(forwardButtonPressed:)]; self.actionButton = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemAction target:self action:@selector(actionButtonPressed:)]; From 1cee6e6693b2bc7c0fcbd4e9eb59dd6ff2ccb4d7 Mon Sep 17 00:00:00 2001 From: David Muir Date: Thu, 3 Sep 2015 21:17:02 -0400 Subject: [PATCH 20/39] Added ability to load NSURLRequest. --- ExampleProject/Podfile | 3 ++- KINWebBrowser/KINWebBrowserViewController.h | 11 ++++++++--- KINWebBrowser/KINWebBrowserViewController.m | 10 +++++++--- 3 files changed, 17 insertions(+), 7 deletions(-) diff --git a/ExampleProject/Podfile b/ExampleProject/Podfile index f6e689e..59e5a9a 100644 --- a/ExampleProject/Podfile +++ b/ExampleProject/Podfile @@ -3,4 +3,5 @@ source 'https://github.com/CocoaPods/Specs.git' xcodeproj 'KINWebBrowserExample.xcodeproj' platform :ios, :deployment_target => '7.0' -pod 'KINWebBrowser', :head +pod 'KINWebBrowser', :git => 'https://github.com/dfmuir/KINWebBrowser.git', :branch => 'dev' + diff --git a/KINWebBrowser/KINWebBrowserViewController.h b/KINWebBrowser/KINWebBrowserViewController.h index 70f1f6c..162d2ae 100644 --- a/KINWebBrowser/KINWebBrowserViewController.h +++ b/KINWebBrowser/KINWebBrowserViewController.h @@ -117,16 +117,21 @@ #pragma mark - Public Interface -// Load a NSURL to webView + +// Load a NSURLURLRequest to web view +// Can be called any time after initialization +- (void)loadRequest:(NSURLRequest *)request; + +// Load a NSURL to web view // Can be called any time after initialization - (void)loadURL:(NSURL *)URL; -// Loads a URL as NSString to webView +// Loads a URL as NSString to web view // Can be called any time after initialization - (void)loadURLString:(NSString *)URLString; -// Loads an string containing HTML to webView +// Loads an string containing HTML to web view // Can be called any time after initialization - (void)loadHTMLString:(NSString *)HTMLString; diff --git a/KINWebBrowser/KINWebBrowserViewController.m b/KINWebBrowser/KINWebBrowserViewController.m index 4a563c9..9a88464 100644 --- a/KINWebBrowser/KINWebBrowserViewController.m +++ b/KINWebBrowser/KINWebBrowserViewController.m @@ -174,15 +174,19 @@ - (void)viewWillDisappear:(BOOL)animated { #pragma mark - Public Interface -- (void)loadURL:(NSURL *)URL { +- (void)loadRequest:(NSURLRequest *)request { if(self.wkWebView) { - [self.wkWebView loadRequest:[NSURLRequest requestWithURL:URL]]; + [self.wkWebView loadRequest:request]; } else if(self.uiWebView) { - [self.uiWebView loadRequest:[NSURLRequest requestWithURL:URL]]; + [self.uiWebView loadRequest:request]; } } +- (void)loadURL:(NSURL *)URL { + [self loadRequest:[NSURLRequest requestWithURL:URL]]; +} + - (void)loadURLString:(NSString *)URLString { NSURL *URL = [NSURL URLWithString:URLString]; [self loadURL:URL]; From 9d61980edad03d10aa2f9305a20af97868a62911 Mon Sep 17 00:00:00 2001 From: David Muir Date: Thu, 3 Sep 2015 21:27:44 -0400 Subject: [PATCH 21/39] Fixed crash issue for UIActivityViewController when page fails to load. --- KINWebBrowser.podspec | 2 +- KINWebBrowser/KINWebBrowserViewController.m | 53 +++++++++++---------- 2 files changed, 30 insertions(+), 25 deletions(-) diff --git a/KINWebBrowser.podspec b/KINWebBrowser.podspec index a1e1876..c7fd4b1 100644 --- a/KINWebBrowser.podspec +++ b/KINWebBrowser.podspec @@ -20,6 +20,6 @@ Pod::Spec.new do |s| s.weak_framework = 'WebKit' s.dependency 'TUSafariActivity', '1.0.4' - s.dependency 'ARChromeActivity', '1.0.2' + s.dependency 'ARChromeActivity', '1.0.4' end \ No newline at end of file diff --git a/KINWebBrowser/KINWebBrowserViewController.m b/KINWebBrowser/KINWebBrowserViewController.m index 9a88464..06c966a 100644 --- a/KINWebBrowser/KINWebBrowserViewController.m +++ b/KINWebBrowser/KINWebBrowserViewController.m @@ -471,30 +471,32 @@ - (void)actionButtonPressed:(id)sender { URLForActivityItem = self.uiWebView.request.URL; URLTitle = [self.uiWebView stringByEvaluatingJavaScriptFromString:@"document.title"]; } - dispatch_async(dispatch_get_main_queue(), ^{ - TUSafariActivity *safariActivity = [[TUSafariActivity alloc] init]; - ARChromeActivity *chromeActivity = [[ARChromeActivity alloc] init]; - - NSMutableArray *activities = [[NSMutableArray alloc] init]; - [activities addObject:safariActivity]; - [activities addObject:chromeActivity]; - if(self.customActivityItems != nil) { - [activities addObjectsFromArray:self.customActivityItems]; - } - - UIActivityViewController *controller = [[UIActivityViewController alloc] initWithActivityItems:@[URLForActivityItem] applicationActivities:activities]; - - if([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPad) { - if(self.actionPopoverController) { - [self.actionPopoverController dismissPopoverAnimated:YES]; + if (URLForActivityItem) { + dispatch_async(dispatch_get_main_queue(), ^{ + TUSafariActivity *safariActivity = [[TUSafariActivity alloc] init]; + ARChromeActivity *chromeActivity = [[ARChromeActivity alloc] init]; + + NSMutableArray *activities = [[NSMutableArray alloc] init]; + [activities addObject:safariActivity]; + [activities addObject:chromeActivity]; + if(self.customActivityItems != nil) { + [activities addObjectsFromArray:self.customActivityItems]; } - self.actionPopoverController = [[UIPopoverController alloc] initWithContentViewController:controller]; - [self.actionPopoverController presentPopoverFromBarButtonItem:self.actionButton permittedArrowDirections: UIPopoverArrowDirectionAny animated:YES]; - } - else { - [self presentViewController:controller animated:YES completion:NULL]; - } - }); + + UIActivityViewController *controller = [[UIActivityViewController alloc] initWithActivityItems:@[URLForActivityItem] applicationActivities:activities]; + + if([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPad) { + if(self.actionPopoverController) { + [self.actionPopoverController dismissPopoverAnimated:YES]; + } + self.actionPopoverController = [[UIPopoverController alloc] initWithContentViewController:controller]; + [self.actionPopoverController presentPopoverFromBarButtonItem:self.actionButton permittedArrowDirections: UIPopoverArrowDirectionAny animated:YES]; + } + else { + [self presentViewController:controller animated:YES completion:NULL]; + } + }); + } } @@ -566,7 +568,10 @@ - (BOOL)externalAppRequiredToOpenURL:(NSURL *)URL { - (void)launchExternalAppWithURL:(NSURL *)URL { self.URLToLaunchWithPermission = URL; - [self.externalAppPermissionAlertView show]; + if (![self.externalAppPermissionAlertView isVisible]) { + [self.externalAppPermissionAlertView show]; + } + } #pragma mark - UIAlertViewDelegate From 1792bd48ea0514a5d19e94b884e17b1e4e695afd Mon Sep 17 00:00:00 2001 From: David Muir Date: Thu, 3 Sep 2015 21:34:14 -0400 Subject: [PATCH 22/39] Reverted podfile from development configuration. --- ExampleProject/Podfile | 2 +- KINWebBrowser.podspec | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/ExampleProject/Podfile b/ExampleProject/Podfile index 59e5a9a..063e61b 100644 --- a/ExampleProject/Podfile +++ b/ExampleProject/Podfile @@ -3,5 +3,5 @@ source 'https://github.com/CocoaPods/Specs.git' xcodeproj 'KINWebBrowserExample.xcodeproj' platform :ios, :deployment_target => '7.0' -pod 'KINWebBrowser', :git => 'https://github.com/dfmuir/KINWebBrowser.git', :branch => 'dev' +pod 'KINWebBrowser' diff --git a/KINWebBrowser.podspec b/KINWebBrowser.podspec index c7fd4b1..d379322 100644 --- a/KINWebBrowser.podspec +++ b/KINWebBrowser.podspec @@ -22,4 +22,4 @@ Pod::Spec.new do |s| s.dependency 'TUSafariActivity', '1.0.4' s.dependency 'ARChromeActivity', '1.0.4' -end \ No newline at end of file +end From 9db6402ed81503351c2f6193bd88439b7147025c Mon Sep 17 00:00:00 2001 From: David Muir Date: Thu, 3 Sep 2015 21:38:48 -0400 Subject: [PATCH 23/39] Updated podspec to version 1.3.0 --- KINWebBrowser.podspec | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/KINWebBrowser.podspec b/KINWebBrowser.podspec index d379322..cd02a64 100644 --- a/KINWebBrowser.podspec +++ b/KINWebBrowser.podspec @@ -2,7 +2,7 @@ Pod::Spec.new do |s| s.name = "KINWebBrowser" - s.version = "1.2.4" + s.version = "1.3.0" s.summary = "A web browser module for your apps." s.description = <<-DESC KINWebBrowser is a web browser module for your apps. Powered by WKWebView on iOS 8. Backwards compatible with iOS 7 using UIWebView. KINWebBrowser offers the simplest way to add a web browser to your apps. @@ -14,7 +14,6 @@ Pod::Spec.new do |s| s.platform = :ios, '7.0' s.source = { :git => "https://github.com/dfmuir/KINWebBrowser.git", :tag => s.version.to_s } s.source_files = 'KINWebBrowser', 'KINWebBrowser/**/*.{h,m}' - s.resources = "Assets/*.png" s.requires_arc = true s.weak_framework = 'WebKit' From b18a051543ff93aa3a95391dea0685ce79a8fd2a Mon Sep 17 00:00:00 2001 From: David Muir Date: Thu, 3 Sep 2015 21:39:08 -0400 Subject: [PATCH 24/39] Updated podspec to version 1.3.0 --- KINWebBrowser.podspec | 1 + 1 file changed, 1 insertion(+) diff --git a/KINWebBrowser.podspec b/KINWebBrowser.podspec index cd02a64..70a262c 100644 --- a/KINWebBrowser.podspec +++ b/KINWebBrowser.podspec @@ -14,6 +14,7 @@ Pod::Spec.new do |s| s.platform = :ios, '7.0' s.source = { :git => "https://github.com/dfmuir/KINWebBrowser.git", :tag => s.version.to_s } s.source_files = 'KINWebBrowser', 'KINWebBrowser/**/*.{h,m}' + s.resources = "Assets/*.png" s.requires_arc = true s.weak_framework = 'WebKit' From eba71bab4516eb9b143360ddc54894a3f761b560 Mon Sep 17 00:00:00 2001 From: Tiago Martinho Date: Wed, 9 Sep 2015 21:28:37 +0200 Subject: [PATCH 25/39] supported interface orientations returns UIInterfaceOrientationMask instead of NSUInteger to eliminate Xcode warnings --- KINWebBrowser/KINWebBrowserViewController.m | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/KINWebBrowser/KINWebBrowserViewController.m b/KINWebBrowser/KINWebBrowserViewController.m index 06c966a..25c53d6 100644 --- a/KINWebBrowser/KINWebBrowserViewController.m +++ b/KINWebBrowser/KINWebBrowserViewController.m @@ -596,7 +596,7 @@ - (void)dismissAnimated:(BOOL)animated { #pragma mark - Interface Orientation -- (NSUInteger)supportedInterfaceOrientations { +- (UIInterfaceOrientationMask)supportedInterfaceOrientations { return UIInterfaceOrientationMaskAllButUpsideDown; } From 8cf6fb269788ee213ba0be6b735ce945338fcc70 Mon Sep 17 00:00:00 2001 From: David Muir Date: Thu, 1 Oct 2015 12:30:19 -0400 Subject: [PATCH 26/39] Updated podspec to 1.3.1 --- KINWebBrowser.podspec | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/KINWebBrowser.podspec b/KINWebBrowser.podspec index 70a262c..41cb5d9 100644 --- a/KINWebBrowser.podspec +++ b/KINWebBrowser.podspec @@ -2,7 +2,7 @@ Pod::Spec.new do |s| s.name = "KINWebBrowser" - s.version = "1.3.0" + s.version = "1.3.1" s.summary = "A web browser module for your apps." s.description = <<-DESC KINWebBrowser is a web browser module for your apps. Powered by WKWebView on iOS 8. Backwards compatible with iOS 7 using UIWebView. KINWebBrowser offers the simplest way to add a web browser to your apps. From 520f7f59450779118c14ce0ceb6246a056cdce3c Mon Sep 17 00:00:00 2001 From: developforapple Date: Mon, 12 Oct 2015 18:39:42 +0800 Subject: [PATCH 27/39] Fix Bug Fix Bug --- KINWebBrowser/KINWebBrowserViewController.h | 2 +- KINWebBrowser/KINWebBrowserViewController.m | 9 +++++++++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/KINWebBrowser/KINWebBrowserViewController.h b/KINWebBrowser/KINWebBrowserViewController.h index 162d2ae..1399a08 100644 --- a/KINWebBrowser/KINWebBrowserViewController.h +++ b/KINWebBrowser/KINWebBrowserViewController.h @@ -64,7 +64,7 @@ For convenience, two sets of static initializers are available. */ -@interface KINWebBrowserViewController : UIViewController +@interface KINWebBrowserViewController : UIViewController #pragma mark - Public Properties diff --git a/KINWebBrowser/KINWebBrowserViewController.m b/KINWebBrowser/KINWebBrowserViewController.m index 25c53d6..52fd600 100644 --- a/KINWebBrowser/KINWebBrowserViewController.m +++ b/KINWebBrowser/KINWebBrowserViewController.m @@ -125,6 +125,7 @@ - (void)viewDidLoad { [self.wkWebView setFrame:self.view.bounds]; [self.wkWebView setAutoresizingMask:UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight]; [self.wkWebView setNavigationDelegate:self]; + [self.wkWebView setUIDelegate:self]; [self.wkWebView setMultipleTouchEnabled:YES]; [self.wkWebView setAutoresizesSubviews:YES]; [self.wkWebView.scrollView setAlwaysBounceVertical:YES]; @@ -334,6 +335,14 @@ - (void)webView:(WKWebView *)webView decidePolicyForNavigationAction:(WKNavigati decisionHandler(WKNavigationActionPolicyAllow); } +#pragma mark - WKUIDelegate +- (WKWebView *)webView:(WKWebView *)webView createWebViewWithConfiguration:(WKWebViewConfiguration *)configuration forNavigationAction:(WKNavigationAction *)navigationAction windowFeatures:(WKWindowFeatures *)windowFeatures{ + if (!navigationAction.targetFrame.isMainFrame) { + [webView loadRequest:navigationAction.request]; + } + return nil; +} + #pragma mark - Toolbar State - (void)updateToolbarState { From 975578fe1d000726e86a30d40bdb48e137dab750 Mon Sep 17 00:00:00 2001 From: Philippe Riegert Date: Tue, 20 Oct 2015 15:32:25 -0400 Subject: [PATCH 28/39] made the actionButton property public so we can access it when we need it for "presentFromBarButtonItem: animated: completionHandler:" on an iPad --- KINWebBrowser/KINWebBrowserViewController.h | 2 +- KINWebBrowser/KINWebBrowserViewController.m | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/KINWebBrowser/KINWebBrowserViewController.h b/KINWebBrowser/KINWebBrowserViewController.h index 162d2ae..4d0161c 100644 --- a/KINWebBrowser/KINWebBrowserViewController.h +++ b/KINWebBrowser/KINWebBrowserViewController.h @@ -105,7 +105,7 @@ + (UINavigationController *)navigationControllerWithWebBrowserWithConfiguration:(WKWebViewConfiguration *)configuration NS_AVAILABLE_IOS(8_0); - +@property (nonatomic, strong) UIBarButtonItem *actionButton; @property (nonatomic, strong) UIColor *tintColor; @property (nonatomic, strong) UIColor *barTintColor; @property (nonatomic, assign) BOOL actionButtonHidden; diff --git a/KINWebBrowser/KINWebBrowserViewController.m b/KINWebBrowser/KINWebBrowserViewController.m index 25c53d6..e05b218 100644 --- a/KINWebBrowser/KINWebBrowserViewController.m +++ b/KINWebBrowser/KINWebBrowserViewController.m @@ -40,7 +40,7 @@ @interface KINWebBrowserViewController () @property (nonatomic, assign) BOOL previousNavigationControllerToolbarHidden, previousNavigationControllerNavigationBarHidden; -@property (nonatomic, strong) UIBarButtonItem *backButton, *forwardButton, *refreshButton, *stopButton, *actionButton, *fixedSeparator, *flexibleSeparator; +@property (nonatomic, strong) UIBarButtonItem *backButton, *forwardButton, *refreshButton, *stopButton, *fixedSeparator, *flexibleSeparator; @property (nonatomic, strong) NSTimer *fakeProgressTimer; @property (nonatomic, strong) UIPopoverController *actionPopoverController; @property (nonatomic, assign) BOOL uiWebViewIsLoading; From 5ec2b3edfc07bf77abf4e01cd6ff2f8dc1289930 Mon Sep 17 00:00:00 2001 From: David Muir Date: Thu, 5 Nov 2015 18:19:04 -0500 Subject: [PATCH 29/39] Cleaned up pull requests. --- KINWebBrowser/KINWebBrowserViewController.m | 1 + 1 file changed, 1 insertion(+) diff --git a/KINWebBrowser/KINWebBrowserViewController.m b/KINWebBrowser/KINWebBrowserViewController.m index e0d212c..253cd25 100644 --- a/KINWebBrowser/KINWebBrowserViewController.m +++ b/KINWebBrowser/KINWebBrowserViewController.m @@ -336,6 +336,7 @@ - (void)webView:(WKWebView *)webView decidePolicyForNavigationAction:(WKNavigati } #pragma mark - WKUIDelegate + - (WKWebView *)webView:(WKWebView *)webView createWebViewWithConfiguration:(WKWebViewConfiguration *)configuration forNavigationAction:(WKNavigationAction *)navigationAction windowFeatures:(WKWindowFeatures *)windowFeatures{ if (!navigationAction.targetFrame.isMainFrame) { [webView loadRequest:navigationAction.request]; From 2b749ebcf4e5df4867b903cc98f92adfa125750e Mon Sep 17 00:00:00 2001 From: David Muir Date: Thu, 5 Nov 2015 18:19:28 -0500 Subject: [PATCH 30/39] Updated ARChromeAcitivity to the most recent version. --- KINWebBrowser.podspec | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/KINWebBrowser.podspec b/KINWebBrowser.podspec index 41cb5d9..95d971d 100644 --- a/KINWebBrowser.podspec +++ b/KINWebBrowser.podspec @@ -2,7 +2,7 @@ Pod::Spec.new do |s| s.name = "KINWebBrowser" - s.version = "1.3.1" + s.version = "1.3.2" s.summary = "A web browser module for your apps." s.description = <<-DESC KINWebBrowser is a web browser module for your apps. Powered by WKWebView on iOS 8. Backwards compatible with iOS 7 using UIWebView. KINWebBrowser offers the simplest way to add a web browser to your apps. @@ -20,6 +20,6 @@ Pod::Spec.new do |s| s.weak_framework = 'WebKit' s.dependency 'TUSafariActivity', '1.0.4' - s.dependency 'ARChromeActivity', '1.0.4' + s.dependency 'ARChromeActivity', '1.0.5' end From ecf914257ac44e261f47311c925e0df7fe34b7ca Mon Sep 17 00:00:00 2001 From: ReadmeCritic Date: Thu, 11 Feb 2016 09:57:33 -0800 Subject: [PATCH 31/39] Correct the spelling of CocoaPods in README --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index a1cf578..573f037 100644 --- a/README.md +++ b/README.md @@ -47,7 +47,7 @@ KINWebBrowserViewController *webBrowser = [webBrowserNavigationController rootWe Installation ------------------------ -#### Cocoapods +#### CocoaPods [CocoaPods](http://cocoapods.org) is a dependency manager for Objective-C, which automates and simplifies the process of using 3rd-party libraries in your projects. See the ["Getting Started" for more information](http://guides.cocoapods.org/using/getting-started.html). ###### Podfile From 3403195c73535470357a85fe6ec95b0690d57791 Mon Sep 17 00:00:00 2001 From: Mattia Valzelli Date: Tue, 31 May 2016 11:33:55 +0200 Subject: [PATCH 32/39] Use [KINWebBrowserViewController class] instead of [self class]. Using [KINWebBrowserViewController class] instead of [self class] allows to retrieve back/forward images correctly when subclassing KINWebBrowserViewController. If you subclass KINWebBrowserViewController (including it in your application using CocoaPods with framework) the path to the image resource could be wrong. This fixes the problem. --- KINWebBrowser/KINWebBrowserViewController.m | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/KINWebBrowser/KINWebBrowserViewController.m b/KINWebBrowser/KINWebBrowserViewController.m index 253cd25..5355114 100644 --- a/KINWebBrowser/KINWebBrowserViewController.m +++ b/KINWebBrowser/KINWebBrowserViewController.m @@ -405,7 +405,7 @@ - (void)updateToolbarState { } - (void)setupToolbarItems { - NSBundle *bundle = [NSBundle bundleForClass:[self class]]; + NSBundle *bundle = [NSBundle bundleForClass:[KINWebBrowserViewController class]]; self.refreshButton = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemRefresh target:self action:@selector(refreshButtonPressed:)]; self.stopButton = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemStop target:self action:@selector(stopButtonPressed:)]; From f0390876bfd2b0abae7096f13d7ee73d3c69c325 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Matthias=20Radm=C3=BCller?= Date: Mon, 5 Oct 2020 16:30:24 +0200 Subject: [PATCH 33/39] feat: updated example project to ios 8.0 minimum-version --- .../project.pbxproj | 3 + .../xcshareddata/IDEWorkspaceChecks.plist | 8 ++ .../AppIcon.appiconset/Contents.json | 86 ++++++++++++++----- ExampleProject/Podfile | 2 +- 4 files changed, 75 insertions(+), 24 deletions(-) create mode 100644 ExampleProject/KINWebBrowserExample.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist diff --git a/ExampleProject/KINWebBrowserExample.xcodeproj/project.pbxproj b/ExampleProject/KINWebBrowserExample.xcodeproj/project.pbxproj index 1d2ff60..6657463 100644 --- a/ExampleProject/KINWebBrowserExample.xcodeproj/project.pbxproj +++ b/ExampleProject/KINWebBrowserExample.xcodeproj/project.pbxproj @@ -230,6 +230,7 @@ developmentRegion = English; hasScannedForEncodings = 0; knownRegions = ( + English, en, ); mainGroup = 3BBECF1C18A1E58D00A2499D; @@ -427,6 +428,7 @@ GCC_PRECOMPILE_PREFIX_HEADER = YES; GCC_PREFIX_HEADER = "KINWebBrowserExample/KINWebBrowserExample-Prefix.pch"; INFOPLIST_FILE = "KINWebBrowserExample/KINWebBrowserExample-Info.plist"; + IPHONEOS_DEPLOYMENT_TARGET = 8.0; PRODUCT_NAME = "$(TARGET_NAME)"; WRAPPER_EXTENSION = app; }; @@ -441,6 +443,7 @@ GCC_PRECOMPILE_PREFIX_HEADER = YES; GCC_PREFIX_HEADER = "KINWebBrowserExample/KINWebBrowserExample-Prefix.pch"; INFOPLIST_FILE = "KINWebBrowserExample/KINWebBrowserExample-Info.plist"; + IPHONEOS_DEPLOYMENT_TARGET = 8.0; PRODUCT_NAME = "$(TARGET_NAME)"; WRAPPER_EXTENSION = app; }; diff --git a/ExampleProject/KINWebBrowserExample.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist b/ExampleProject/KINWebBrowserExample.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist new file mode 100644 index 0000000..18d9810 --- /dev/null +++ b/ExampleProject/KINWebBrowserExample.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist @@ -0,0 +1,8 @@ + + + + + IDEDidComputeMac32BitWarning + + + diff --git a/ExampleProject/KINWebBrowserExample/Images.xcassets/AppIcon.appiconset/Contents.json b/ExampleProject/KINWebBrowserExample/Images.xcassets/AppIcon.appiconset/Contents.json index b7f3352..9221b9b 100644 --- a/ExampleProject/KINWebBrowserExample/Images.xcassets/AppIcon.appiconset/Contents.json +++ b/ExampleProject/KINWebBrowserExample/Images.xcassets/AppIcon.appiconset/Contents.json @@ -2,57 +2,97 @@ "images" : [ { "idiom" : "iphone", - "size" : "29x29", - "scale" : "2x" + "scale" : "2x", + "size" : "20x20" }, { "idiom" : "iphone", - "size" : "40x40", - "scale" : "2x" + "scale" : "3x", + "size" : "20x20" }, { "idiom" : "iphone", - "size" : "60x60", - "scale" : "2x" + "scale" : "2x", + "size" : "29x29" }, { "idiom" : "iphone", - "size" : "60x60", - "scale" : "3x" + "scale" : "3x", + "size" : "29x29" + }, + { + "idiom" : "iphone", + "scale" : "2x", + "size" : "40x40" + }, + { + "idiom" : "iphone", + "scale" : "3x", + "size" : "40x40" + }, + { + "idiom" : "iphone", + "scale" : "2x", + "size" : "60x60" + }, + { + "idiom" : "iphone", + "scale" : "3x", + "size" : "60x60" }, { "idiom" : "ipad", - "size" : "29x29", - "scale" : "1x" + "scale" : "1x", + "size" : "20x20" }, { "idiom" : "ipad", - "size" : "29x29", - "scale" : "2x" + "scale" : "2x", + "size" : "20x20" }, { "idiom" : "ipad", - "size" : "40x40", - "scale" : "1x" + "scale" : "1x", + "size" : "29x29" }, { "idiom" : "ipad", - "size" : "40x40", - "scale" : "2x" + "scale" : "2x", + "size" : "29x29" }, { "idiom" : "ipad", - "size" : "76x76", - "scale" : "1x" + "scale" : "1x", + "size" : "40x40" }, { "idiom" : "ipad", - "size" : "76x76", - "scale" : "2x" + "scale" : "2x", + "size" : "40x40" + }, + { + "idiom" : "ipad", + "scale" : "1x", + "size" : "76x76" + }, + { + "idiom" : "ipad", + "scale" : "2x", + "size" : "76x76" + }, + { + "idiom" : "ipad", + "scale" : "2x", + "size" : "83.5x83.5" + }, + { + "idiom" : "ios-marketing", + "scale" : "1x", + "size" : "1024x1024" } ], "info" : { - "version" : 1, - "author" : "xcode" + "author" : "xcode", + "version" : 1 } -} \ No newline at end of file +} diff --git a/ExampleProject/Podfile b/ExampleProject/Podfile index 063e61b..ce76fad 100644 --- a/ExampleProject/Podfile +++ b/ExampleProject/Podfile @@ -1,7 +1,7 @@ source 'https://github.com/CocoaPods/Specs.git' xcodeproj 'KINWebBrowserExample.xcodeproj' -platform :ios, :deployment_target => '7.0' +platform :ios, :deployment_target => '8.0' pod 'KINWebBrowser' From 25f8fffb226d344b5a714af1ac45cc3bcb7d3f90 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Matthias=20Radm=C3=BCller?= Date: Mon, 5 Oct 2020 16:32:29 +0200 Subject: [PATCH 34/39] feat: removed deprected UIWebView fixes #69 --- KINWebBrowser.podspec | 6 +- KINWebBrowser/KINWebBrowserViewController.h | 10 +- KINWebBrowser/KINWebBrowserViewController.m | 221 +++----------------- README.md | 6 +- 4 files changed, 39 insertions(+), 204 deletions(-) diff --git a/KINWebBrowser.podspec b/KINWebBrowser.podspec index 95d971d..745c86d 100644 --- a/KINWebBrowser.podspec +++ b/KINWebBrowser.podspec @@ -2,16 +2,16 @@ Pod::Spec.new do |s| s.name = "KINWebBrowser" - s.version = "1.3.2" + s.version = "1.3.3" s.summary = "A web browser module for your apps." s.description = <<-DESC - KINWebBrowser is a web browser module for your apps. Powered by WKWebView on iOS 8. Backwards compatible with iOS 7 using UIWebView. KINWebBrowser offers the simplest way to add a web browser to your apps. + KINWebBrowser is a web browser module for your apps. Powered by WKWebView on iOS 8. KINWebBrowser offers the simplest way to add a web browser to your apps. DESC s.homepage = "https://github.com/dfmuir/KINWebBrowser" s.license = { :type => 'MIT', :file => 'LICENSE' } s.author = { "David F. Muir V" => "dfmuir@gmail.com" } - s.platform = :ios, '7.0' + s.platform = :ios, '8.0' s.source = { :git => "https://github.com/dfmuir/KINWebBrowser.git", :tag => s.version.to_s } s.source_files = 'KINWebBrowser', 'KINWebBrowser/**/*.{h,m}' s.resources = "Assets/*.png" diff --git a/KINWebBrowser/KINWebBrowserViewController.h b/KINWebBrowser/KINWebBrowserViewController.h index 64a5087..c580547 100644 --- a/KINWebBrowser/KINWebBrowserViewController.h +++ b/KINWebBrowser/KINWebBrowserViewController.h @@ -31,7 +31,6 @@ // #import -#import @class KINWebBrowserViewController; @@ -64,7 +63,7 @@ For convenience, two sets of static initializers are available. */ -@interface KINWebBrowserViewController : UIViewController +@interface KINWebBrowserViewController : UIViewController #pragma mark - Public Properties @@ -76,9 +75,8 @@ // The web views // Depending on the version of iOS, one of these will be set @property (nonatomic, strong) WKWebView *wkWebView; -@property (nonatomic, strong) UIWebView *uiWebView; -- (id)initWithConfiguration:(WKWebViewConfiguration *)configuration NS_AVAILABLE_IOS(8_0); +- (id)initWithConfiguration:(WKWebViewConfiguration *)configuration #pragma mark - Static Initializers @@ -91,7 +89,7 @@ */ + (KINWebBrowserViewController *)webBrowser; -+ (KINWebBrowserViewController *)webBrowserWithConfiguration:(WKWebViewConfiguration *)configuration NS_AVAILABLE_IOS(8_0); ++ (KINWebBrowserViewController *)webBrowserWithConfiguration:(WKWebViewConfiguration *)configuration /* Initialize a UINavigationController with a KINWebBrowserViewController for modal presentation. @@ -102,7 +100,7 @@ */ + (UINavigationController *)navigationControllerWithWebBrowser; -+ (UINavigationController *)navigationControllerWithWebBrowserWithConfiguration:(WKWebViewConfiguration *)configuration NS_AVAILABLE_IOS(8_0); ++ (UINavigationController *)navigationControllerWithWebBrowserWithConfiguration:(WKWebViewConfiguration *)configuration @property (nonatomic, strong) UIBarButtonItem *actionButton; diff --git a/KINWebBrowser/KINWebBrowserViewController.m b/KINWebBrowser/KINWebBrowserViewController.m index 5355114..21055e2 100644 --- a/KINWebBrowser/KINWebBrowserViewController.m +++ b/KINWebBrowser/KINWebBrowserViewController.m @@ -41,10 +41,7 @@ @interface KINWebBrowserViewController () @property (nonatomic, assign) BOOL previousNavigationControllerToolbarHidden, previousNavigationControllerNavigationBarHidden; @property (nonatomic, strong) UIBarButtonItem *backButton, *forwardButton, *refreshButton, *stopButton, *fixedSeparator, *flexibleSeparator; -@property (nonatomic, strong) NSTimer *fakeProgressTimer; @property (nonatomic, strong) UIPopoverController *actionPopoverController; -@property (nonatomic, assign) BOOL uiWebViewIsLoading; -@property (nonatomic, strong) NSURL *uiWebViewCurrentURL; @property (nonatomic, strong) NSURL *URLToLaunchWithPermission; @property (nonatomic, strong) UIAlertView *externalAppPermissionAlertView; @@ -91,18 +88,14 @@ - (id)init { - (id)initWithConfiguration:(WKWebViewConfiguration *)configuration { self = [super init]; if(self) { - if([WKWebView class]) { - if(configuration) { - self.wkWebView = [[WKWebView alloc] initWithFrame:CGRectZero configuration:configuration]; - } - else { - self.wkWebView = [[WKWebView alloc] init]; - } + if(configuration) { + self.wkWebView = [[WKWebView alloc] initWithFrame:CGRectZero configuration:configuration]; } else { - self.uiWebView = [[UIWebView alloc] init]; + self.wkWebView = [[WKWebView alloc] init]; } + self.actionButtonHidden = NO; self.showsURLInNavigationBar = NO; self.showsPageTitleInNavigationBar = YES; @@ -121,28 +114,16 @@ - (void)viewDidLoad { self.previousNavigationControllerToolbarHidden = self.navigationController.toolbarHidden; self.previousNavigationControllerNavigationBarHidden = self.navigationController.navigationBarHidden; - if(self.wkWebView) { - [self.wkWebView setFrame:self.view.bounds]; - [self.wkWebView setAutoresizingMask:UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight]; - [self.wkWebView setNavigationDelegate:self]; - [self.wkWebView setUIDelegate:self]; - [self.wkWebView setMultipleTouchEnabled:YES]; - [self.wkWebView setAutoresizesSubviews:YES]; - [self.wkWebView.scrollView setAlwaysBounceVertical:YES]; - [self.view addSubview:self.wkWebView]; - - [self.wkWebView addObserver:self forKeyPath:NSStringFromSelector(@selector(estimatedProgress)) options:0 context:KINWebBrowserContext]; - } - else if(self.uiWebView) { - [self.uiWebView setFrame:self.view.bounds]; - [self.uiWebView setAutoresizingMask:UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight]; - [self.uiWebView setDelegate:self]; - [self.uiWebView setMultipleTouchEnabled:YES]; - [self.uiWebView setAutoresizesSubviews:YES]; - [self.uiWebView setScalesPageToFit:YES]; - [self.uiWebView.scrollView setAlwaysBounceVertical:YES]; - [self.view addSubview:self.uiWebView]; - } + [self.wkWebView setFrame:self.view.bounds]; + [self.wkWebView setAutoresizingMask:UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight]; + [self.wkWebView setNavigationDelegate:self]; + [self.wkWebView setUIDelegate:self]; + [self.wkWebView setMultipleTouchEnabled:YES]; + [self.wkWebView setAutoresizesSubviews:YES]; + [self.wkWebView.scrollView setAlwaysBounceVertical:YES]; + [self.view addSubview:self.wkWebView]; + + [self.wkWebView addObserver:self forKeyPath:NSStringFromSelector(@selector(estimatedProgress)) options:0 context:KINWebBrowserContext]; self.progressView = [[UIProgressView alloc] initWithProgressViewStyle:UIProgressViewStyleDefault]; @@ -169,19 +150,13 @@ - (void)viewWillDisappear:(BOOL)animated { [self.navigationController setToolbarHidden:self.previousNavigationControllerToolbarHidden animated:animated]; - [self.uiWebView setDelegate:nil]; [self.progressView removeFromSuperview]; } #pragma mark - Public Interface - (void)loadRequest:(NSURLRequest *)request { - if(self.wkWebView) { - [self.wkWebView loadRequest:request]; - } - else if(self.uiWebView) { - [self.uiWebView loadRequest:request]; - } + [self.wkWebView loadRequest:request]; } - (void)loadURL:(NSURL *)URL { @@ -194,12 +169,7 @@ - (void)loadURLString:(NSString *)URLString { } - (void)loadHTMLString:(NSString *)HTMLString { - if(self.wkWebView) { - [self.wkWebView loadHTMLString:HTMLString baseURL:nil]; - } - else if(self.uiWebView) { - [self.uiWebView loadHTMLString:HTMLString baseURL:nil]; - } + [self.wkWebView loadHTMLString:HTMLString baseURL:nil]; } - (void)setTintColor:(UIColor *)tintColor { @@ -220,61 +190,6 @@ - (void)setActionButtonHidden:(BOOL)actionButtonHidden { [self updateToolbarState]; } - -#pragma mark - UIWebViewDelegate - -- (BOOL)webView:(UIWebView *)webView shouldStartLoadWithRequest:(NSURLRequest *)request navigationType:(UIWebViewNavigationType)navigationType { - if(webView == self.uiWebView) { - - if(![self externalAppRequiredToOpenURL:request.URL]) { - self.uiWebViewCurrentURL = request.URL; - self.uiWebViewIsLoading = YES; - [self updateToolbarState]; - - [self fakeProgressViewStartLoading]; - - if([self.delegate respondsToSelector:@selector(webBrowser:didStartLoadingURL:)]) { - [self.delegate webBrowser:self didStartLoadingURL:request.URL]; - } - return YES; - } - else { - [self launchExternalAppWithURL:request.URL]; - return NO; - } - } - return NO; -} - -- (void)webViewDidFinishLoad:(UIWebView *)webView { - if(webView == self.uiWebView) { - if(!self.uiWebView.isLoading) { - self.uiWebViewIsLoading = NO; - [self updateToolbarState]; - - [self fakeProgressBarStopLoading]; - } - - if([self.delegate respondsToSelector:@selector(webBrowser:didFinishLoadingURL:)]) { - [self.delegate webBrowser:self didFinishLoadingURL:self.uiWebView.request.URL]; - } - } -} - -- (void)webView:(UIWebView *)webView didFailLoadWithError:(NSError *)error { - if(webView == self.uiWebView) { - if(!self.uiWebView.isLoading) { - self.uiWebViewIsLoading = NO; - [self updateToolbarState]; - - [self fakeProgressBarStopLoading]; - } - if([self.delegate respondsToSelector:@selector(webBrowser:didFailToLoadURL:error:)]) { - [self.delegate webBrowser:self didFailToLoadURL:self.uiWebView.request.URL error:error]; - } - } -} - #pragma mark - WKNavigationDelegate - (void)webView:(WKWebView *)webView didStartProvisionalNavigation:(WKNavigation *)navigation { @@ -348,8 +263,8 @@ - (WKWebView *)webView:(WKWebView *)webView createWebViewWithConfiguration:(WKWe - (void)updateToolbarState { - BOOL canGoBack = self.wkWebView.canGoBack || self.uiWebView.canGoBack; - BOOL canGoForward = self.wkWebView.canGoForward || self.uiWebView.canGoForward; + BOOL canGoBack = self.wkWebView.canGoBack + BOOL canGoForward = self.wkWebView.canGoForward [self.backButton setEnabled:canGoBack]; [self.forwardButton setEnabled:canGoForward]; @@ -359,17 +274,11 @@ - (void)updateToolbarState { } NSArray *barButtonItems; - if(self.wkWebView.loading || self.uiWebViewIsLoading) { + if(self.wkWebView.loading) { barButtonItems = @[self.backButton, self.fixedSeparator, self.forwardButton, self.fixedSeparator, self.stopButton, self.flexibleSeparator]; if(self.showsURLInNavigationBar) { - NSString *URLString; - if(self.wkWebView) { - URLString = [self.wkWebView.URL absoluteString]; - } - else if(self.uiWebView) { - URLString = [self.uiWebViewCurrentURL absoluteString]; - } + NSString *URLString = [self.wkWebView.URL absoluteString]; URLString = [URLString stringByReplacingOccurrencesOfString:@"http://" withString:@""]; URLString = [URLString stringByReplacingOccurrencesOfString:@"https://" withString:@""]; @@ -381,12 +290,7 @@ - (void)updateToolbarState { barButtonItems = @[self.backButton, self.fixedSeparator, self.forwardButton, self.fixedSeparator, self.refreshButton, self.flexibleSeparator]; if(self.showsPageTitleInNavigationBar) { - if(self.wkWebView) { - self.navigationItem.title = self.wkWebView.title; - } - else if(self.uiWebView) { - self.navigationItem.title = [self.uiWebView stringByEvaluatingJavaScriptFromString:@"document.title"]; - } + self.navigationItem.title = self.wkWebView.title; } } @@ -430,57 +334,29 @@ - (void)doneButtonPressed:(id)sender { #pragma mark - UIBarButtonItem Target Action Methods - (void)backButtonPressed:(id)sender { - - if(self.wkWebView) { - [self.wkWebView goBack]; - } - else if(self.uiWebView) { - [self.uiWebView goBack]; - } + [self.wkWebView goBack]; [self updateToolbarState]; } - (void)forwardButtonPressed:(id)sender { - if(self.wkWebView) { - [self.wkWebView goForward]; - } - else if(self.uiWebView) { - [self.uiWebView goForward]; - } + [self.wkWebView goForward]; [self updateToolbarState]; } - (void)refreshButtonPressed:(id)sender { - if(self.wkWebView) { - [self.wkWebView stopLoading]; - [self.wkWebView reload]; - } - else if(self.uiWebView) { - [self.uiWebView stopLoading]; - [self.uiWebView reload]; - } + [self.wkWebView stopLoading]; + [self.wkWebView reload]; } - (void)stopButtonPressed:(id)sender { - if(self.wkWebView) { - [self.wkWebView stopLoading]; - } - else if(self.uiWebView) { - [self.uiWebView stopLoading]; - } + [self.wkWebView stopLoading]; } - (void)actionButtonPressed:(id)sender { NSURL *URLForActivityItem; NSString *URLTitle; - if(self.wkWebView) { - URLForActivityItem = self.wkWebView.URL; - URLTitle = self.wkWebView.title; - } - else if(self.uiWebView) { - URLForActivityItem = self.uiWebView.request.URL; - URLTitle = [self.uiWebView stringByEvaluatingJavaScriptFromString:@"document.title"]; - } + URLForActivityItem = self.wkWebView.URL; + URLTitle = self.wkWebView.title; if (URLForActivityItem) { dispatch_async(dispatch_get_main_queue(), ^{ TUSafariActivity *safariActivity = [[TUSafariActivity alloc] init]; @@ -532,43 +408,6 @@ - (void)observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change:(N } } - -#pragma mark - Fake Progress Bar Control (UIWebView) - -- (void)fakeProgressViewStartLoading { - [self.progressView setProgress:0.0f animated:NO]; - [self.progressView setAlpha:1.0f]; - - if(!self.fakeProgressTimer) { - self.fakeProgressTimer = [NSTimer scheduledTimerWithTimeInterval:1.0f/60.0f target:self selector:@selector(fakeProgressTimerDidFire:) userInfo:nil repeats:YES]; - } -} - -- (void)fakeProgressBarStopLoading { - if(self.fakeProgressTimer) { - [self.fakeProgressTimer invalidate]; - } - - if(self.progressView) { - [self.progressView setProgress:1.0f animated:YES]; - [UIView animateWithDuration:0.3f delay:0.3f options:UIViewAnimationOptionCurveEaseOut animations:^{ - [self.progressView setAlpha:0.0f]; - } completion:^(BOOL finished) { - [self.progressView setProgress:0.0f animated:NO]; - }]; - } -} - -- (void)fakeProgressTimerDidFire:(id)sender { - CGFloat increment = 0.005/(self.progressView.progress + 0.2); - if([self.uiWebView isLoading]) { - CGFloat progress = (self.progressView.progress < 0.75f) ? self.progressView.progress + increment : self.progressView.progress + 0.0005; - if(self.progressView.progress < 0.95) { - [self.progressView setProgress:progress animated:YES]; - } - } -} - #pragma mark - External App Support - (BOOL)externalAppRequiredToOpenURL:(NSURL *)URL { @@ -616,9 +455,7 @@ - (BOOL)shouldAutorotate { #pragma mark - Dealloc -- (void)dealloc { - [self.uiWebView setDelegate:nil]; - +- (void)dealloc { [self.wkWebView setNavigationDelegate:nil]; [self.wkWebView setUIDelegate:nil]; if ([self isViewLoaded]) { diff --git a/README.md b/README.md index 573f037..d12eef2 100644 --- a/README.md +++ b/README.md @@ -3,13 +3,13 @@ KINWebBrowser KINWebBrowser is a web browser module for your apps. -Powered by [WKWebView](https://developer.apple.com/library/IOs/documentation/WebKit/Reference/WKWebView_Ref/index.html) on iOS 8. Backwards compatible with iOS 7 using [UIWebView](https://developer.apple.com/library/ios/documentation/Uikit/reference/UIWebView_Class/index.html). +Powered by [WKWebView](https://developer.apple.com/library/IOs/documentation/WebKit/Reference/WKWebView_Ref/index.html) on iOS 8. ![KINWebBrowser Screenshots](http://i.imgur.com/z1jkWKG.png) Features ------------------------ -* iOS 7 & 8 support for iPhone and iPad devices +* iOS 8 support for iPhone and iPad devices * Safari-like interface * Animated progress bar * Customizable UI including tint color @@ -53,7 +53,7 @@ Installation ###### Podfile ```ruby -platform :ios, '7.0' +platform :ios, '8.0' pod 'KINWebBrowser' ``` From 97f3fca622c0f188a121215a166e8926fb1272a1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Matthias=20Radm=C3=BCller?= Date: Mon, 5 Oct 2020 16:39:35 +0200 Subject: [PATCH 35/39] Update KINWebBrowserViewController.h feat: removed deprecated UIWebView fixes #69 --- KINWebBrowser/KINWebBrowserViewController.h | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/KINWebBrowser/KINWebBrowserViewController.h b/KINWebBrowser/KINWebBrowserViewController.h index c580547..59aee36 100644 --- a/KINWebBrowser/KINWebBrowserViewController.h +++ b/KINWebBrowser/KINWebBrowserViewController.h @@ -31,6 +31,7 @@ // #import +#import @class KINWebBrowserViewController; @@ -76,7 +77,7 @@ // Depending on the version of iOS, one of these will be set @property (nonatomic, strong) WKWebView *wkWebView; -- (id)initWithConfiguration:(WKWebViewConfiguration *)configuration +- (id)initWithConfiguration:(WKWebViewConfiguration *)configuration; #pragma mark - Static Initializers @@ -89,7 +90,7 @@ */ + (KINWebBrowserViewController *)webBrowser; -+ (KINWebBrowserViewController *)webBrowserWithConfiguration:(WKWebViewConfiguration *)configuration ++ (KINWebBrowserViewController *)webBrowserWithConfiguration:(WKWebViewConfiguration *)configuration; /* Initialize a UINavigationController with a KINWebBrowserViewController for modal presentation. From cc7aa47a2418901f652a85da5e08d45a805f565a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Matthias=20Radm=C3=BCller?= Date: Mon, 5 Oct 2020 16:44:55 +0200 Subject: [PATCH 36/39] feat: removed deprecated UIWebView fixes #69 --- KINWebBrowser/KINWebBrowserViewController.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/KINWebBrowser/KINWebBrowserViewController.h b/KINWebBrowser/KINWebBrowserViewController.h index 59aee36..d45206a 100644 --- a/KINWebBrowser/KINWebBrowserViewController.h +++ b/KINWebBrowser/KINWebBrowserViewController.h @@ -101,7 +101,7 @@ */ + (UINavigationController *)navigationControllerWithWebBrowser; -+ (UINavigationController *)navigationControllerWithWebBrowserWithConfiguration:(WKWebViewConfiguration *)configuration ++ (UINavigationController *)navigationControllerWithWebBrowserWithConfiguration:(WKWebViewConfiguration *)configuration; @property (nonatomic, strong) UIBarButtonItem *actionButton; From 11f724ffa30bc1228c712985c8237fa9a45a17b7 Mon Sep 17 00:00:00 2001 From: matrad Date: Mon, 12 Oct 2020 14:12:48 +0200 Subject: [PATCH 37/39] feat: removed deprecated UIWebView fixes dfmuir#69 --- KINWebBrowser/KINWebBrowserViewController.m | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/KINWebBrowser/KINWebBrowserViewController.m b/KINWebBrowser/KINWebBrowserViewController.m index 21055e2..f3524bc 100644 --- a/KINWebBrowser/KINWebBrowserViewController.m +++ b/KINWebBrowser/KINWebBrowserViewController.m @@ -263,8 +263,8 @@ - (WKWebView *)webView:(WKWebView *)webView createWebViewWithConfiguration:(WKWe - (void)updateToolbarState { - BOOL canGoBack = self.wkWebView.canGoBack - BOOL canGoForward = self.wkWebView.canGoForward + BOOL canGoBack = self.wkWebView.canGoBack; + BOOL canGoForward = self.wkWebView.canGoForward; [self.backButton setEnabled:canGoBack]; [self.forwardButton setEnabled:canGoForward]; From e777e8a6ae2ad6e8ae15ce90c5d819b221fba671 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tim=20A=C3=9Fmann?= Date: Wed, 9 Mar 2022 23:29:53 +0100 Subject: [PATCH 38/39] fix merge conflict gone wrong remove duplicate decidePolicyForNavigationAction method --- KINWebBrowser/KINWebBrowserViewController.m | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/KINWebBrowser/KINWebBrowserViewController.m b/KINWebBrowser/KINWebBrowserViewController.m index 9b7b90e..449a345 100644 --- a/KINWebBrowser/KINWebBrowserViewController.m +++ b/KINWebBrowser/KINWebBrowserViewController.m @@ -192,14 +192,6 @@ - (void)setActionButtonHidden:(BOOL)actionButtonHidden { #pragma mark - WKNavigationDelegate -- (void)webView:(WKWebView *)webView decidePolicyForNavigationAction:(WKNavigationAction *)navigationAction decisionHandler:(void (^)(WKNavigationActionPolicy))decisionHandler { - NSURLRequest *request = navigationAction.request; - BOOL shouldLoad = YES; - if([self.delegate respondsToSelector:@selector(webBrowser:shouldStartLoadWithRequest:)]) { - shouldLoad = [self.delegate webBrowser:self shouldStartLoadWithRequest:request]; - } - decisionHandler(shouldLoad == YES ? WKNavigationActionPolicyAllow : WKNavigationActionPolicyCancel); -} - (void)webView:(WKWebView *)webView didStartProvisionalNavigation:(WKNavigation *)navigation { if(webView == self.wkWebView) { @@ -259,6 +251,16 @@ - (void)webView:(WKWebView *)webView decidePolicyForNavigationAction:(WKNavigati decisionHandler(WKNavigationActionPolicyAllow); } + +// - (void)webView:(WKWebView *)webView decidePolicyForNavigationAction:(WKNavigationAction *)navigationAction decisionHandler:(void (^)(WKNavigationActionPolicy))decisionHandler { +// NSURLRequest *request = navigationAction.request; +// BOOL shouldLoad = YES; +// if([self.delegate respondsToSelector:@selector(webBrowser:shouldStartLoadWithRequest:)]) { +// shouldLoad = [self.delegate webBrowser:self shouldStartLoadWithRequest:request]; +// } +// decisionHandler(shouldLoad == YES ? WKNavigationActionPolicyAllow : WKNavigationActionPolicyCancel); +// } + #pragma mark - WKUIDelegate - (WKWebView *)webView:(WKWebView *)webView createWebViewWithConfiguration:(WKWebViewConfiguration *)configuration forNavigationAction:(WKNavigationAction *)navigationAction windowFeatures:(WKWindowFeatures *)windowFeatures{ From 87432b532a196cd09a3c3c787adf71f84790b84a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tim=20A=C3=9Fmann?= Date: Wed, 9 Mar 2022 23:46:14 +0100 Subject: [PATCH 39/39] fix another broken method after merge use original doneButtonPressed method --- KINWebBrowser/KINWebBrowserViewController.m | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/KINWebBrowser/KINWebBrowserViewController.m b/KINWebBrowser/KINWebBrowserViewController.m index 449a345..7fa50fd 100644 --- a/KINWebBrowser/KINWebBrowserViewController.m +++ b/KINWebBrowser/KINWebBrowserViewController.m @@ -337,12 +337,15 @@ - (void)setupToolbarItems { } #pragma mark - Done Button Action +// - (void)doneButtonPressed:(id)sender { +// if([self.delegate respondsToSelector:@selector(willDismissWebBrowser:)]) { +// [self.delegate willDismissWebBrowser:self]; +// } +// [self.navigationController dismissViewControllerAnimated:YES completion:nil]; +// } - (void)doneButtonPressed:(id)sender { - if([self.delegate respondsToSelector:@selector(willDismissWebBrowser:)]) { - [self.delegate willDismissWebBrowser:self]; - } - [self.navigationController dismissViewControllerAnimated:YES completion:nil]; + [self dismissAnimated:YES]; }