Giter VIP home page Giter VIP logo

gdwebviewcontroller's Introduction

GDWebViewController v1.4.1

A simple view controller for navigating web pages using WKWebView. iOS 8.1+.

Supports Swift 3.0 and iOS 10 SDK. For Swift 2 support go here

App Screenshots

Description

  • A browser-like view controller to support web pages navigation in your Swift app.
  • Supports back-forward navigation and page refresh action.
  • Supports back-forward swipe gestures.
  • Has built-in activity indicators (both progress view and activity indicator).

Installation

Just grab two files GDWebViewController.swift and GDWebViewNavigationToolbar.swift into your project.
You can download GDWebBrowserClient project as well to see how it can be used.

CocoaPods

CocoaPods is a dependency manager for Cocoa projects. For usage and installation instructions, visit their website. To integrate GDWebViewController into your Xcode project using CocoaPods, specify it in your Podfile:

pod 'GDWebViewController'

GDWebViewController Interface

Properties

weak var delegate: GDWebViewControllerDelegate?

An object to serve as a delegate which conforms to GDWebViewNavigationToolbarDelegate protocol.

var progressIndicatorStyle: GDWebViewControllerProgressIndicatorStyle = .Both

The style of progress indication visualization. Can be one of four values: .ActivityIndicator, .ProgressView, .Both, .None

var allowsBackForwardNavigationGestures: Bool

A Boolean value indicating whether horizontal swipe gestures will trigger back-forward list navigations. The default value is false.

var showsToolbar: Bool

A boolean value if set to true shows the toolbar; otherwise, hides it.

var showsStopRefreshControl: Bool

A boolean value if set to true shows the refresh control (or stop control while loading) on the toolbar; otherwise, hides it.

var toolbar: GDWebViewNavigationToolbar

The navigation toolbar object (read-only).

var allowJavaScriptAlerts: Bool

Boolean flag which indicates whether JavaScript alerts are allowed. Default is true.

Methods

func loadURLWithString(_ URLString: String)

Navigates to an URL created from provided string.

func loadURL(_ URL: Foundation.URL, cachePolicy: NSURLRequest.CachePolicy = .useProtocolCachePolicy, timeoutInterval: TimeInterval = 0)

Navigates to the URL.

func showToolbar(_ show: Bool, animated: Bool)

Shows or hides toolbar.

func evaluateJavaScript(_ javaScriptString: String, completionHandler: ((AnyObject?, NSError?) -> Void)?)

Evaluates the given JavaScript string.

GDWebViewControllerDelegate Methods

@objc public protocol GDWebViewControllerDelegate {
    @objc optional func webViewController(_ webViewController: GDWebViewController, didChangeURL newURL: URL?)
    @objc optional func webViewController(_ webViewController: GDWebViewController, didChangeTitle newTitle: NSString?)
    @objc optional func webViewController(_ webViewController: GDWebViewController, didFinishLoading loadedURL: URL?)
    @objc optional func webViewController(_ webViewController: GDWebViewController, decidePolicyForNavigationAction navigationAction: WKNavigationAction, decisionHandler: (WKNavigationActionPolicy) -> Void)
    @objc optional func webViewController(_ webViewController: GDWebViewController, decidePolicyForNavigationResponse navigationResponse: WKNavigationResponse, decisionHandler: (WKNavigationResponsePolicy) -> Void)
    @objc optional func webViewController(_ webViewController: GDWebViewController, didReceiveAuthenticationChallenge challenge: URLAuthenticationChallenge, completionHandler: (URLSession.AuthChallengeDisposition, URLCredential?) -> Void)
}

Notice:
You must do import WebKit if you use last three methods from GDWebViewControllerDelegate description.

GDWebViewNavigationToolbar Interface

Properties

var toolbarTintColor: UIColor?

The tint color to apply to the toolbar button items.

var toolbarBackgroundColor: UIColor?

The toolbar's background color.

var toolbarTranslucent: Bool

A Boolean value that indicates whether the toolbar is translucent (true) or not (false).

License

Published under MIT license. If you have any feature requests, please create an issue. Smart pull requests are also welcome.

gdwebviewcontroller's People

Contributors

agarbowitzomadahealth avatar bumaociyuan avatar coffellas-cto avatar fsalata avatar xiasenhai avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.