Latest 0.5.0
Homepage https://github.com/mrfour0004/AVScanner
License MIT
Platforms ios 10.0
Authors

CI Status
Version
License
Platform

Example

To run the example project, clone the repo, and run pod install from the Example directory first.

Installation

AVScanner is available through CocoaPods. To install
it, simply add the following line to your Podfile:

pod "AVScanner"

Reguirement

  • iOS 10.0+
  • Xcode 9.0
  • Swift 4.0

Usage

In your UIViewController class, import the following framework

import AVScanner
import AVFoundation

Setup the barcodeHandler:, and bring any views you set up in storyboard or xib to front.

override viewDidLoad() {
    super.viewDidLoad()

    // Set up `supportedMetadataObjectTypes` if needed, 
    // it only support `AVMetadataObjectTypeQRCode` by default.
    supportedMetadataObjectTypes = [.qr, .pdf417]    

    // If you have set up any views in storyboard or xib, remember to bring them to front.
    view.bringSubview(toFront: myView)

    // If you use `self` in this block will result in a retain cycle, 
    // it's your duty to break it through `[unowned self]`.
    barcodeHandler = { barcodeObj in
        loggingPrint("captured barcode: (barcodeObj.stringValue!)")
    }
}

// You can also flip the camera between front and back through invoking `flip()`
@IBAction func buttonClick(_ sender: Any) {
    guard isSessionRunning else { return }
    flip()
}

Attention

When isSessionRunning is false, the autorotate will be disabled. It usually happens when it captures a barcode. However, if the viewController is owned by an UINavigationController or UITabBarController, you have to override sholdAutoRotate in the class of UINavigationController or UITabBarController by yourself.

For more detail, please refer to the exemple project and feel free to contact me.

License

AVScanner is available under the MIT license. See the LICENSE file for more info.

Latest podspec

{
    "name": "AVScanner",
    "version": "0.5.0",
    "summary": "A 1D/2D barcode reader based on AVFoundation.",
    "homepage": "https://github.com/mrfour0004/AVScanner",
    "license": {
        "type": "MIT",
        "file": "LICENSE"
    },
    "authors": {
        "mrfour": "[email protected]"
    },
    "source": {
        "git": "https://github.com/mrfour0004/AVScanner.git",
        "tag": "0.5.0"
    },
    "platforms": {
        "ios": "10.0"
    },
    "source_files": "AVScanner/Classes/**/*"
}

Pin It on Pinterest

Share This