Files
checker/ios/Runner/ScannerViewController.swift

60 lines
1.8 KiB
Swift
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
//
// 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()
}
}