CustomKINWebBrowser 0.2.5

CustomKINWebBrowser 0.2.5

TestsTested
LangLanguage Obj-CObjective C
License MIT
ReleasedLast Release Dec 2014

Maintained by Eddie Li.



 
Depends on:
TUSafariActivity= 1.0.0
ARChromeActivity>= 0
 

  • By
  • Eddie Li

KINWebBrowser

KINWebBrowser is a web browser module for your apps. Compatible with iPhone and iPad devices running iOS 7 & 8.

KINWebBrowser Screenshots

Features

  • iOS 7 & 8 support for iPhone and iPad
  • Customizable UI
  • Portrait and landscape orientation support
  • Use with existing UINavigationController or present modally
  • Load URL from NSURL or NSString
  • Delegate protocol for status callbacks
  • Action button to allow users to copy URL, share, or open in Safari & Google Chrome
  • Supports subclassing
  • Installation with CocoaPods

Overview

KINWebBrowser consists of a single component:

  • KINWebBrowserViewController - a UIViewController that contains a full featured web browser.

KINWebBrowserViewController must be contained in a UINavigationController.

Pushing to the navigation stack:

KINWebBrowserViewController *webBrowser = [KINWebBrowserViewController webBrowserViewController];
[self.navigationController pushViewController:webBrowser animated:YES];
[webBrowser loadURLString:@"http://www.example.com"];

Presenting Modally:

UINavigationController *webBrowserNavigationController = [KINWebBrowserViewController navigationControllerWithWebBrowser];
[self presentViewController:webBrowserNavigationController animated:YES completion:nil];

KINWebBrowserViewController *webBrowser = [webBrowserNavigationController rootWebBrowserViewController];
[webBrowser loadURLString:@"http://www.example.com"];

Podfile

platform :ios, '7.0'
pod 'KINWebBrowser', '~> 0.2.5'

Implementing KINWebBrowserDelegate Protocol

KINWebBrowserDelegate is a set of @optional callback methods to inform the delegate of NSURLRequest status changes.

- (void)webBrowser:(KINWebBrowserViewController *)webBrowser didBeginLoadingRequest:(NSURLRequest *)request;

- (void)webBrowser:(KINWebBrowserViewController *)webBrowser didFinishLoadingRequest:(NSURLRequest *)request;

- (void)webBrowser:(KINWebBrowserViewController *)webBrowser didFailToLoadRequest:(NSURLRequest *)request withError:(NSError *)error;

Customizing the User Interface

The user interface of KINWebBrowserViewController can be customized at initialization using an NSDictionary of boolean NSNumber values.

// Create an NSDictionary containing the keys and NSNumber booelan values 
NSDictionary *options = @{
                            KINWebBrowserShowsActionButton : @YES,
                            KINWebBrowserShowsProgressView : @NO
                        };
// Create a KINWebBrowserViewController instance with the specified options
[KINWebBrowserViewController webBrowserWithOptions:options];
/* Create a UINavigationController with the rootViewController containing
 an instance of KINWebBrowserViewController instance with the specified options */

[KINWebBrowserViewController navigationControllerWithWebBrowserWithOptions:options];

The following values can be customized

Key Default Value Description
KINWebBrowserShowsActionButton YES Shows the action button. When enabled the action button launches a UIActivityViewController with the URL to copy to the clipboard, share, or launch Safari or Google Chrome. This displays in a UIPopoverController on iPad devices.
KINWebBrowserShowsProgressView YES Shows a Safari-like progress view in the UINavigationBar that displays the loading progress of the request.
KINWebBrowserShowsPageTitleInNavigationBar YES Once loading is complete, shows the of the URL in the UINavigationBar
KINWebBrowserShowsPageURLInNavigationBar YES During loading, shows the URL in the UINavigationBar
KINWebBrowserRestoresNavigationBarState YES Restores the navigationBarHidden state from before KINWebBrowserViewController was pushed onto the navigation stack. Useful since KINWebBrowserViewController explicitly sets navigationBarHidden to NO. There is very little reason to set this value to NO
KINWebBrowserRestoresToolbarState YES Restores the toolbarBarHidden state from before KINWebBrowserViewController was pushed onto the navigation stack. Useful since KINWebBrowserViewController explicitly sets toolbarBarHidden to NO.