Запускается ZBAR сканнер в iOS версии приложения
This commit is contained in:
59
ios/Runner/ScannerViewController.swift
Normal file
59
ios/Runner/ScannerViewController.swift
Normal file
@@ -0,0 +1,59 @@
|
||||
//
|
||||
// ScannerViewController.swift
|
||||
// Runner
|
||||
//
|
||||
// Created by Ivan Murashov on 13/07/2017.
|
||||
// Copyright © 2017 The Chromium Authors. All rights reserved.
|
||||
//
|
||||
|
||||
import UIKit
|
||||
|
||||
extension ZBarSymbolSet: Sequence {
|
||||
public typealias Element = ZBarSymbol
|
||||
public typealias Iterator = NSFastEnumerationIterator
|
||||
|
||||
public func makeIterator() -> NSFastEnumerationIterator {
|
||||
return NSFastEnumerationIterator(self)
|
||||
}
|
||||
}
|
||||
|
||||
// TODO: Реализовать окно сканнера в этом контроллере, вместо вызова ZBarReaderViewController
|
||||
|
||||
@objc class ScannerViewController: UIViewController, ZBarReaderDelegate {
|
||||
|
||||
override func viewDidLoad() {
|
||||
super.viewDidLoad()
|
||||
}
|
||||
|
||||
override func viewDidAppear(_ animated: Bool) {
|
||||
super.viewDidAppear(animated)
|
||||
let readerViewController = ZBarReaderViewController()
|
||||
readerViewController.readerDelegate = self
|
||||
readerViewController.readerView.zoom = 1.0
|
||||
readerViewController.showsZBarControls = false
|
||||
self.present(readerViewController, animated: true)
|
||||
}
|
||||
|
||||
func imagePickerController(_ picker: UIImagePickerController, didFinishPickingMediaWithInfo info: [String : Any]) {
|
||||
guard let symbols = info[ZBarReaderControllerResults] as? ZBarSymbolSet else { return }
|
||||
|
||||
for symbol in symbols {
|
||||
|
||||
if let symbol = symbol as? ZBarSymbol, let data = symbol.data {
|
||||
|
||||
let toast = UIAlertView()
|
||||
toast.message = data
|
||||
toast.show()
|
||||
|
||||
navigationController?.popViewController(animated: true)
|
||||
}
|
||||
}
|
||||
navigationController?.popViewController(animated: true)
|
||||
|
||||
}
|
||||
|
||||
override func didReceiveMemoryWarning() {
|
||||
super.didReceiveMemoryWarning()
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user