FUITextRecognitionViewController

open class FUITextRecognitionViewController : UIViewController

The FUITextRecognitionViewController is convenience controller embedding FUITextRecognitionView view which captures video from device back camera and performs text recognition. For more example to how to configure text recognition check out the FUITextRecognitionView documentation.

## Example Initialization and Configuration


 textRecController = FUITextRecognitionViewController()
 //additional phone number detector to filter out observations
 let detector = try! NSDataDetector.init(types: NSTextCheckingResult.CheckingType.phoneNumber.rawValue)

 var frameCount = 10 //capture the observations after 10 frames
 textRecController.recognitionView.observationHandler = { observations in
    //use NSDataDetector extensions to run matches on observations
    let matches = detector.matches(in: observations)
    textRecController.recognitionView.showTexts(for: observations, with: matches)
    frameCount -= 1
    if frameCount < 0 {
        DispatchQueue.main.async {
            var phoneNumber: String?
            for match in matches where match.resultType == .phoneNumber {
                    phoneNumber = match.phoneNumber
            }
            textView.text = phoneNumber ?? ""
            dismiss(animated: true)
        }
        return true
    }
    return false
}

 textRecController.onClose = {
    dismiss(animated: true)
 }

 present(UINavigationController(rootViewController: textRecController), animated: true)
  • Can be used to customize closeButton

    Declaration

    Swift

    public private(set) var closeButton: UIBarButtonItem! { get }
  • Can be used to customize flashButton

    Declaration

    Swift

    public private(set) var flashButton: UIBarButtonItem! { get }
  • The effective UINavigationController.

    Developer could set this to the UINavigationController for this view controller. If developer did not set this value, the UINavigationController of this view controller will be returned if it is not nil. Otherwise, the root UINavigationController from the keyWindow, if any, will be returned.

    Declaration

    Swift

    public var effectiveNavigationController: UINavigationController? { get set }
  • Called when closeButton is tapped

    Declaration

    Swift

    public var onClose: (() -> Void)?
  • The backing view which captures video and performs text recognition

    Declaration

    Swift

    public let recognitionView: FUITextRecognitionView
  • Creates a FUITextRecognitionViewController object.

    Declaration

    Swift

    public init(style: FUITextRecognitionView.Style = .singleField)

    Parameters

    style

    A constant specifies the style of recognition view. Default value is .singleField.

  • Undocumented

    Declaration

    Swift

    open override func viewWillAppear(_ animated: Bool)
  • Undocumented

    Declaration

    Swift

    open override func viewWillDisappear(_ animated: Bool)