mikebuss / MTBBarcodeScanner

A lightweight, easy-to-use barcode scanning library for iOS 8+

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Implement CaptureStillImage

frozts91 opened this issue · comments

Hi @mikebuss i want to implement function captureStillImage on Swift 3, in the doc you said implement after start scanning, how to do that?

try self.scanner?.startScanning(resultBlock: { codes in
    self.scanner?.freezeCapture()
     self.scanner?.captureStillImage({ (UIImage?, Error?) in
                            code
                        })

is that correct? because its return nil

I wasn't aware of this limitation so I didn't document it, but the session must be running in order to capture a still image. So, calling freezeCapture before captureStillImage won't work - you'll have to capture the still image and then freeze.

I have tried this and it works, but let me know if you run in to any issues:

self.scanner?.captureStillImage({ (image, error) in
    NSLog("The image and/or error are accessible here");
})
self.scanner?.freezeCapture()