onPreCapture

Description

This event is fired before an image or a document is captured.

Syntax

delegate func onPreCapture(sender:Any)

Parameters

sender:Any The current DcsUIVideoView object that triggers the event.

Return value

Bool

Remarks

If YES is returned, the capture action is continued; if NO is returned, the capture action is cancelled and the event onCaptureFailure is not fired.

Example

class ViewController: UIViewController, DcsUIVideoViewDelegate {
    var dcsView:DcsView!
    override func viewDidLoad() {
        super.viewDidLoad()
        dcsView = DcsView(frame: CGRect(x:0,y:0,width:self.view.frame.size.width,height:self.view.frame.size.height))
        dcsView.videoView.delegate = self
        view.addSubview(dcsView)
    }
    func onDocumentDetected(_ sender: Any!, document: DcsDocument!) {
        print("Document is detected")
    }
    func onCancelTapped(_ sender: Any!) {
        print("Cancel is tapped")
    }
    func onCaptureTapped(_ sender: Any!) {
        print("Capture is tapped")
    }
    func onPreCapture(_ sender: Any!) -> Bool {
        print("This event is fired before capture")
        //If false is returned, the capture action will be cancelled.
        return true
    }
    func onPostCapture(_ sender: Any!) {
        print("This event is fired after capture")
    }
    func onCaptureFailure(_ sender: Any!, exception: DcsException!) {
        print("Capture failed")
    }
}
Is this page helpful?