Giter VIP home page Giter VIP logo

swiftwebvc's Introduction

SwiftWebVC

SwiftWebVC is a simple inline browser for your Swift iOS app.

SwiftWebVC

SwiftWebVC features:

  • iPhone and iPad distinct UIs
  • Full landscape orientation support
  • Back, forward, stop/refresh and share buttons
  • Open in Safari and Chrome UIActivities
  • Navbar title set to the currently visible web page
  • Talks with setNetworkActivityIndicatorVisible
  • 3 different themes to choose from when presented modally

SwiftWebVC

Installation

CocoaPods

  • SwiftWebVC is available through CocoaPods. To install it, simply add the following line to your Podfile:
pod 'SwiftWebVC'

Carthage

Carthage is a decentralized dependency manager that builds your dependencies and provides you with binary frameworks.

You can install Carthage with Homebrew using the following command:

$ brew update
$ brew install carthage

To integrate SwiftWebVC into your Xcode project using Carthage, specify it in your Cartfile:

github "meismyles/SwiftWebVC"

Run carthage update to build the framework and drag the built SwiftWebVC.framework into your Xcode project.

Manual

  • Add the SwiftWebVC/ folder into your project.

Usage

Just like any UIViewController, SwiftWebVC can be pushed into a UINavigationController stack:

let webVC = SwiftWebVC(urlString: "http://google.com")
self.navigationController?.pushViewController(webVC, animated: true)

It can be presented modally using SwiftModalWebVC:

let webVC = SwiftModalWebVC(urlString: "http://google.com")
self.present(webVC, animated: true, completion: nil)

Options

The share button can be disabled by passing a flag in to the constructor to specify this:

let webVC = SwiftWebVC(urlString: "http://google.com", sharingEnabled: false)

The same principal applies for the modal implementation also:

let webVC = SwiftModalWebVC(urlString: "http://google.com", sharingEnabled: false)

Modal Options Only

Themes may be chosen for the modal implementation. The default theme is Light-Blue. Other modal themes Light-Black and Dark may be chosen using one of the following instead:

let webVC = SwiftModalWebVC(urlString: "http://google.com", theme: .lightBlack)
let webVC = SwiftModalWebVC(urlString: "http://google.com", theme: .dark)

Delegate (Start/Finish Loading Callbacks)

SwiftWebVC also includes a delegate protocol that allows you to implement didStartLoading and didFinishLoading functions to determine when loading starts and finishes.

Note: This is currently only implemented for SwiftWebVC, not SwiftModalWebVC.

To implement this, after declaring your instance of SwiftWebVC, set it's delegate and implement the callback functions. For example:

Inititalisation

let webVC = SwiftWebVC(urlString: "https://www.google.com")
webVC.delegate = self
self.navigationController?.pushViewController(webVC, animated: true)

Delegate Implementation

extension ViewController: SwiftWebVCDelegate {
    
    func didStartLoading() {
        print("Started loading.")
    }
    
    func didFinishLoading(success: Bool) {
        print("Finished loading. Success: \(success).")
    }
}

SwiftWebVCActivity

Starting in iOS 6 Apple uses UIActivity to let you show additional sharing methods in share sheets. SwiftWebVC comes with "Open in Safari" and "Open in Chrome" activities. You can easily add your own activity by subclassing SwiftWebVCActivity which takes care of a few things automatically for you. Have a look at the Safari and Chrome activities for implementation examples.Typed

Credits

SwiftWebVC is a Swift implementation of Sam Vermette's SVWebViewController. Code transcription, updates and changes were carried out by Myles Ringle. The original SVWebViewController was brought to you by Sam Vermette and contributors to the project.

If you have feature suggestions or bug reports, feel free to help out by sending pull requests or by creating new issues. If you're using SwiftWebVC in your project, attribution is always appreciated.

Thanks to Icons8 for the images.

swiftwebvc's People

Contributors

meismyles avatar bchrobot avatar igorkulman avatar lfarah avatar alroman avatar antigp avatar azhararmar avatar mwilliams123 avatar ntnhon avatar jalakoo avatar

Watchers

James Cloos 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.