Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
217 views
in Technique[技术] by (71.8m points)

ios - How to apply barcode scanner to UIView, beginner level

What I'm trying to accomplish is to have the bottom half of a screen to be an active qr-code scanner, and the other half of the screen to be a tableview. Whenever I scan a qr-code, it will check the tableview for a match and highlight it.

What would i need to use to make this happen?

I'm using the following cocoapod for the qr code (https://cocoapods.org/pods/QRCodeReader.swift).

This is what my viewcontroller looks like:

import UIKit
import QRCodeReader

class myviewcontroller: UIViewController {


    // THIS IS MY UIVIEW VARIABLE FROM STORYBOARD.
    @IBOutlet var Uiview: UIView!

    override func viewDidLoad()
    {
        super.viewDidLoad()

    }

}

The cocoapods has instructions for how to insert the view, but i have no idea how to apply it (i am very new to uiviews), here is their instructions:

class YourCustomView: UIView, QRCodeReaderDisplayable {
  let cameraView: UIView            = UIView()
  let cancelButton: UIButton?       = UIButton()
  let switchCameraButton: UIButton? = SwitchCameraButton()
  let toggleTorchButton: UIButton?  = ToggleTorchButton()
  var overlayView: UIView?          = UIView()

  func setupComponents(with builder: QRCodeReaderViewControllerBuilder) {
    // addSubviews
    // setup constraints
    // etc.
  }
}

lazy var reader: QRCodeReaderViewController = {
    let builder = QRCodeReaderViewControllerBuilder {
      let readerView = QRCodeReaderContainer(displayable: YourCustomView())

      $0.readerView = readerView
    }
    
    return QRCodeReaderViewController(builder: builder)
  }()

Would appreciate any help regarding this!

question from:https://stackoverflow.com/questions/66055457/how-to-apply-barcode-scanner-to-uiview-beginner-level

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)
Waitting for answers

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...