Latest 1.0.0
Homepage https://github.com/slashkeys/QRCodeCaptureViewController
License MIT
Platforms ios 9.0
Authors

Description

QRCodeCaptureViewController is a subclass of UIViewController that allows you to capture and decode QRCodes.

Usage

Firstly you have to add QRCodeCaptureViewController to your Podfile:

pod QRCodeCaptureViewController

Then just run pod install or pod update and everything should set up for you. 🎉

To use QRCodeCaptureViewController you have to make your ViewController-Class a subclass of QRCodeCaptureViewController. That’s all. 😉 When your ViewController get’s loaded the camera input of your device is streamed to the screen and you’re ready to decode the QRCode.

👆 Don’t forget to import the QRCodeCaptureViewController first.

import QRCodeCaptureViewController

class ViewController: QRCodeCaptureViewController {
    override func viewDidLoad() {
        super.viewDidLoad(animated)

        delegate = self
    }
}

Initializer

If you want to instanciate the ViewController programmaticly you can use the Initializer method of QRCodeCaptureViewController.

QRCodeCaptureDelegate

The QRCodeCaptureDelegate requires you to embed one function inside of the ViewController it is set to. The function is called didDecodeQRCode() and takes two parameters.

  1. withString: String 👉 the decoded String
  2. byViewController: QRCodeCaptureViewController 👉 a reference to the ViewController used to decode the QRCode

Passing in the ViewController allows you to decode a QRCode on one ViewController and e.g. update the text of a UILabel on another ViewController.

extension ViewController: QRCodeCaptureDelegate {
    func didDecodeQRCode(withString string: String, byViewController vc: QRCodeCaptureViewController) {
        print("Successfully decoded QRCode: (string)")
    }
}

Latest podspec

{
    "name": "QRCodeCaptureViewController",
    "version": "1.0.0",
    "summary": "UIViewController-Subclass for capturing and decoding QRCodes",
    "description": "The QRCodeCaptureViewController class provides a simple way for capturing QRCodes and decode them on the fly. With the QRCodeCaptureDelegate you can capture a QRCode in one ViewController and show the decoded String on another one.",
    "homepage": "https://github.com/slashkeys/QRCodeCaptureViewController",
    "license": {
        "type": "MIT",
        "file": "LICENSE"
    },
    "authors": {
        "Slashkeys": "[email protected]"
    },
    "social_media_url": "http://twitter.com/slashkeysdev",
    "platforms": {
        "ios": "9.0"
    },
    "source": {
        "git": "https://github.com/slashkeys/QRCodeCaptureViewController.git",
        "tag": "1.0.0"
    },
    "source_files": [
        "Classes",
        "QRCodeCaptureViewController"
    ]
}

Pin It on Pinterest

Share This