Code Monkey home page Code Monkey logo

qrcoder's Introduction

QRCoder

CI Status Version License Platform

Since OSX 10.9 / iOS 7 apple offers a CI filter to generate QR codes. However, scaling the QR code to the desired size without blurring the image doesn't work out of the box. The QRCoder library can help you with that. It also contains a handy view controller to scan QR codes (iOS only).

Usage: Generator

Simply use an instance of QRCodeGenerator to create an image of type QRImage. This is a type alias for UIImage under iOS and NSImage under OS X.

let generator = QRCodeGenerator()
//Default correction level is M
generator.correctionLevel = .H
let image:QRImage = generator.createImage("Hello world!",size: CGSizeMake(200,200))

let generator = QRCodeGenerator()
let image:QRImage = generator.createImage("Hello world!",size: CGSizeMake(200,200))

You can set the correction level to one of the values [L,M,Q,H]. The meaning is as follows:

  • Level L – up to 7% damage
  • Level M – up to 15% damage
  • Level Q – up to 25% damage
  • Level H – up to 30% damage

Example usage:

let generator = QRCodeGenerator(correctionLevel: .H)

Usage: Scanner (iOS)

class ScannerViewController : QRCodeScannerViewController {

    override func processQRCodeContent(qrCodeContent: String) -> Bool {
        println(qrCodeContent)
        dismissViewControllerAnimated(true, completion: nil)
        return true
    }

    override func didFailWithError(error: NSError) {
        let alert = UIAlertController(title: error.localizedDescription,
            message: error.localizedFailureReason, preferredStyle: .Alert)
        let okAction = UIAlertAction(title: "OK", style: .Default, handler: {
            _ in
            self.dismissViewControllerAnimated(true, completion: nil)
        })
        alert.addAction(okAction)
        presentViewController(alert, animated: true, completion: nil)
    }

}

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

Requirements

Requires OS X 10.9 / iOS 8.

Installation

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

pod "QRCoder"

Version Compatibility

Current Swift compatibility breakdown:

Swift Version Framework Version
4.1 1.x
2.3 0.x

Todo

  • Add QR code scanner for OS X

Contributing

  • Fork it
  • Create new branch to make your changes
  • Commit all your changes to your branch
  • Submit a pull request

Author

Sebastian Hunkeler, @sbhklr

License

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

qrcoder's People

Contributors

luketlancaster avatar sebromero avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

qrcoder's Issues

appearing camera

HI @sbhklr,
while implementing this pod successfully working in simulator but displaying camera in device.As I expected is show the Generated qrCode not Camera to scan @sbhklr in simulater showing directly the qrCode screen that was perfect but while running in the device camera screen without capturing button appearing
img_0005
simulator screen shot - iphone 6s - 2018-11-02 at 10 48 44

Show webpage

I want to show webpage after scan. how can i do that?

Swift 4 support?

Is this library still maintained? Swift is now around version 4.1 and this libs can't even run at Swift 3?

Text Encoding problem

Hi @sbhklr,
It seems that non-ASCII characters (e.g. 你好, おはよう) cannot be encoded correctly. When I scan the generated QR code, those non-ASCII characters are replaced with question mark ?.

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.