Updating documentations
This commit is contained in:
parent
319194e650
commit
59ce1b2d9c
|
@ -6,7 +6,7 @@ Released on 2016-06-15.
|
|||
**Swift 3 supports**
|
||||
|
||||
- Use `QRCodeReaderViewControllerBuilder` instead of `QRCodeViewControllerBuilder`
|
||||
- deprecated all initializers expect `initWithBuilder`
|
||||
- Remove all deprecated apis
|
||||
|
||||
`QRCodeReader`:
|
||||
- Use `didFindCode` instead of `didFindCodeBlock`
|
||||
|
@ -15,6 +15,11 @@ Released on 2016-06-15.
|
|||
- `hasFrontDevice` is a property
|
||||
- `isTorchAvailable` is a property
|
||||
|
||||
## [Version 6.2.0](https://github.com/yannickl/QRCodeReader.swift/releases/tag/6.2.0)
|
||||
Released on 2016-09-08.
|
||||
|
||||
- Deprecating all initializers expect `initWithBuilder` in order to remove them in the next version
|
||||
|
||||
## [Version 6.1.0](https://github.com/yannickl/QRCodeReader.swift/releases/tag/6.1.0)
|
||||
Released on 2016-08-03.
|
||||
|
||||
|
|
|
@ -202,13 +202,13 @@
|
|||
CED23DDA1A15079300BE7A72 /* QRCodeReader */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
4A0723DB1C223D8100F2C410 /* QRCodeReaderResult.swift */,
|
||||
CED23DDB1A15079300BE7A72 /* QRCodeReader.swift */,
|
||||
CED23DDD1A1507CB00BE7A72 /* SwitchCameraButton.swift */,
|
||||
CECCE4CC1A1527DE00071669 /* ReaderOverlayView.swift */,
|
||||
4A0723DB1C223D8100F2C410 /* QRCodeReaderResult.swift */,
|
||||
CECD170A1AA3531C00A9ACDE /* QRCodeReaderViewController.swift */,
|
||||
82BD4A091BBC21F800172E4E /* ToggleTorchButton.swift */,
|
||||
CE345B221C444D6400FCC482 /* QRCodeReaderViewControllerBuilder.swift */,
|
||||
CECCE4CC1A1527DE00071669 /* ReaderOverlayView.swift */,
|
||||
CED23DDD1A1507CB00BE7A72 /* SwitchCameraButton.swift */,
|
||||
82BD4A091BBC21F800172E4E /* ToggleTorchButton.swift */,
|
||||
);
|
||||
name = QRCodeReader;
|
||||
path = ../QRCodeReader;
|
||||
|
|
|
@ -28,14 +28,10 @@ import UIKit
|
|||
import AVFoundation
|
||||
|
||||
class ViewController: UIViewController, QRCodeReaderViewControllerDelegate {
|
||||
lazy var reader: QRCodeReaderViewController = {
|
||||
let builder = QRCodeReaderViewControllerBuilder { builder in
|
||||
builder.reader = QRCodeReader(metadataObjectTypes: [AVMetadataObjectTypeQRCode])
|
||||
builder.showTorchButton = true
|
||||
}
|
||||
|
||||
return QRCodeReaderViewController(builder: builder)
|
||||
}()
|
||||
lazy var reader = QRCodeReaderViewController(builder: QRCodeReaderViewControllerBuilder {
|
||||
$0.reader = QRCodeReader(metadataObjectTypes: [AVMetadataObjectTypeQRCode])
|
||||
$0.showTorchButton = true
|
||||
})
|
||||
|
||||
@IBAction func scanAction(_ sender: AnyObject) {
|
||||
if QRCodeReader.supportsMetadataObjectTypes() {
|
||||
|
@ -61,7 +57,7 @@ class ViewController: UIViewController, QRCodeReaderViewControllerDelegate {
|
|||
// MARK: - QRCodeReader Delegate Methods
|
||||
|
||||
func reader(_ reader: QRCodeReaderViewController, didScanResult result: QRCodeReaderResult) {
|
||||
self.dismiss(animated: true) { [weak self] in
|
||||
dismiss(animated: true) { [weak self] in
|
||||
let alert = UIAlertController(
|
||||
title: "QRCodeReader",
|
||||
message: String (format:"%@ (of type %@)", result.value, result.metadataType),
|
||||
|
@ -74,6 +70,6 @@ class ViewController: UIViewController, QRCodeReaderViewControllerDelegate {
|
|||
}
|
||||
|
||||
func readerDidCancel(_ reader: QRCodeReaderViewController) {
|
||||
self.dismiss(animated: true, completion: nil)
|
||||
dismiss(animated: true, completion: nil)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -58,70 +58,6 @@ public class QRCodeReaderViewController: UIViewController {
|
|||
|
||||
// MARK: - Creating the View Controller
|
||||
|
||||
/**
|
||||
Initializes a view controller to read QRCodes from a displayed video preview and a cancel button to be go back.
|
||||
|
||||
- parameter cancelButtonTitle: The title to use for the cancel button.
|
||||
- parameter startScanningAtLoad: Flag to know whether the view controller start scanning the codes when the view will appear.
|
||||
|
||||
:see: init(cancelButtonTitle:, metadataObjectTypes:)
|
||||
*/
|
||||
@available(iOS, deprecated, message: "Use init with builder instead.")
|
||||
convenience public init(cancelButtonTitle: String, startScanningAtLoad: Bool = true) {
|
||||
self.init(cancelButtonTitle: cancelButtonTitle, metadataObjectTypes: [AVMetadataObjectTypeQRCode], startScanningAtLoad: startScanningAtLoad)
|
||||
}
|
||||
|
||||
/**
|
||||
Initializes a reader view controller with a list of metadata object types.
|
||||
|
||||
- parameter metadataObjectTypes: An array of strings identifying the types of metadata objects to process.
|
||||
- parameter startScanningAtLoad: Flag to know whether the view controller start scanning the codes when the view will appear.
|
||||
|
||||
:see: init(cancelButtonTitle:, metadataObjectTypes:)
|
||||
*/
|
||||
@available(iOS, deprecated, message: "Use init with builder instead.")
|
||||
convenience public init(metadataObjectTypes: [String], startScanningAtLoad: Bool = true) {
|
||||
self.init(cancelButtonTitle: "Cancel", metadataObjectTypes: metadataObjectTypes, startScanningAtLoad: startScanningAtLoad)
|
||||
}
|
||||
|
||||
/**
|
||||
Initializes a view controller to read wanted metadata object types from a displayed video preview and a cancel button to be go back.
|
||||
|
||||
- parameter cancelButtonTitle: The title to use for the cancel button.
|
||||
- parameter metadataObjectTypes: An array of strings identifying the types of metadata objects to process.
|
||||
- parameter startScanningAtLoad: Flag to know whether the view controller start scanning the codes when the view will appear.
|
||||
|
||||
:see: init(cancelButtonTitle:, coderReader:, startScanningAtLoad:)
|
||||
*/
|
||||
@available(iOS, deprecated, message: "Use init with builder instead.")
|
||||
convenience public init(cancelButtonTitle: String, metadataObjectTypes: [String], startScanningAtLoad: Bool = true) {
|
||||
let reader = QRCodeReader(metadataObjectTypes: metadataObjectTypes)
|
||||
|
||||
self.init(cancelButtonTitle: cancelButtonTitle, codeReader: reader, startScanningAtLoad: startScanningAtLoad)
|
||||
}
|
||||
|
||||
/**
|
||||
Initializes a view controller using a cancel button title and a code reader.
|
||||
|
||||
- parameter cancelButtonTitle: The title to use for the cancel button.
|
||||
- parameter codeReader: The code reader object used to scan the bar code.
|
||||
- parameter startScanningAtLoad: Flag to know whether the view controller start scanning the codes when the view will appear.
|
||||
- parameter showSwitchCameraButton: Flag to display the switch camera button.
|
||||
- parameter showTorchButton: Flag to display the toggle torch button. If the value is true and there is no torch the button will not be displayed.
|
||||
- parameter showCancelButton: Flag to display the cancel button. True by default.
|
||||
*/
|
||||
@available(iOS, deprecated, message: "Use init with builder instead.")
|
||||
public convenience init(cancelButtonTitle: String, codeReader reader: QRCodeReader, startScanningAtLoad startScan: Bool = true, showSwitchCameraButton showSwitch: Bool = true, showTorchButton showTorch: Bool = false, showCancelButton showCancel: Bool = true) {
|
||||
self.init(builder: QRCodeReaderViewControllerBuilder { builder in
|
||||
builder.cancelButtonTitle = cancelButtonTitle
|
||||
builder.reader = reader
|
||||
builder.startScanningAtLoad = startScan
|
||||
builder.showCancelButton = showCancel
|
||||
builder.showSwitchCameraButton = showSwitch
|
||||
builder.showTorchButton = showTorch
|
||||
})
|
||||
}
|
||||
|
||||
/**
|
||||
Initializes a view controller using a builder.
|
||||
|
||||
|
|
22
README.md
22
README.md
|
@ -15,9 +15,11 @@ It provides a default view controller to display the camera view with the scan a
|
|||
```swift
|
||||
// Good practice: create the reader lazily to avoid cpu overload during the
|
||||
// initialization and each time we need to scan a QRCode
|
||||
lazy var readerVC = QRCodeReaderViewController(metadataObjectTypes: [AVMetadataObjectTypeQRCode])
|
||||
lazy var readerVC = QRCodeReaderViewController(builder: QRCodeReaderViewControllerBuilder {
|
||||
$0.reader = QRCodeReader(metadataObjectTypes: [AVMetadataObjectTypeQRCode])
|
||||
})
|
||||
|
||||
@IBAction func scanAction(sender: AnyObject) {
|
||||
@IBAction func scanAction(_ sender: AnyObject) {
|
||||
// Retrieve the QRCode content
|
||||
// By using the delegate pattern
|
||||
readerVC.delegate = self
|
||||
|
@ -28,18 +30,18 @@ lazy var readerVC = QRCodeReaderViewController(metadataObjectTypes: [AVMetadataO
|
|||
}
|
||||
|
||||
// Presents the readerVC as modal form sheet
|
||||
readerVC.modalPresentationStyle = .FormSheet
|
||||
presentViewController(readerVC, animated: true, completion: nil)
|
||||
readerVC.modalPresentationStyle = .formSheet
|
||||
present(reader, animated: true, completion: nil)
|
||||
}
|
||||
|
||||
// MARK: - QRCodeReader Delegate Methods
|
||||
|
||||
func reader(reader: QRCodeReader, didScanResult result: QRCodeReaderResult) {
|
||||
self.dismissViewControllerAnimated(true, completion: nil)
|
||||
func reader(_ reader: QRCodeReader, didScanResult result: QRCodeReaderResult) {
|
||||
dismiss(animated: true, completion: nil)
|
||||
}
|
||||
|
||||
func readerDidCancel(reader: QRCodeReader) {
|
||||
self.dismissViewControllerAnimated(true, completion: nil)
|
||||
func readerDidCancel(_ reader: QRCodeReader) {
|
||||
dismiss(animated: true, completion: nil)
|
||||
}
|
||||
```
|
||||
|
||||
|
@ -67,7 +69,7 @@ source 'https://github.com/CocoaPods/Specs.git'
|
|||
platform :ios, '8.0'
|
||||
|
||||
use_frameworks!
|
||||
pod 'QRCodeReader.swift', '~> 6.0.0'
|
||||
pod 'QRCodeReader.swift', '~> 7.0.0'
|
||||
```
|
||||
|
||||
Install into your project:
|
||||
|
@ -98,7 +100,7 @@ $ brew install carthage
|
|||
To integrate `QRCodeReader` into your Xcode project using Carthage, specify it in your `Cartfile` file:
|
||||
|
||||
```ogdl
|
||||
github "yannickl/QRCodeReader.swift" >= 6.0.0
|
||||
github "yannickl/QRCodeReader.swift" >= 7.0.0
|
||||
```
|
||||
|
||||
#### Manually
|
||||
|
|
Loading…
Reference in New Issue