首页 > 解决方案 > 像 nativescript 插件一样实现 IRLDocumentScanner CocoaPods

问题描述

我正在寻找实现IRLDocumentScanner CocoaPods 之类的 nativescript 插件。我已经正确安装了 Pod,并测试了我是否可以从IRLScannerViewController.

基于对象 C 的文档已尝试但保存时崩溃!myScanner.ios.ts

import { Common } from './myScanner.common';

declare var IRLScannerViewController: any

export class myScanner extends Common {
    constructor() {
        super()

    }

       public createNativeView() {
        const session = new AVCaptureSession();
        session.sessionPreset = AVCaptureSessionPreset1280x720;

        const device = AVCaptureDevice.defaultDeviceWithMediaType(AVMediaTypeVideo);
        const input = AVCaptureDeviceInput.deviceInputWithDeviceError(device);
        if (!input) {
            throw new Error("Error trying to open camera.");
        }
        session.addInput(input);

        session.startRunning();

        const videoLayer = AVCaptureVideoPreviewLayer.layerWithSession(session);

        const camereraView = UIView.alloc().initWithFrame({ origin: { x: 0, y: 0 }, size: { width: 400, height: 600 } });
        camereraView.backgroundColor = UIColor.blueColor;
        videoLayer.frame = camereraView.bounds;
        camereraView.layer.addSublayer(videoLayer);
        this.cameraView = camereraView
        return this.cameraView
    }

    public initNativeView() {
        let delegate = IRLScannerViewControllerDelegate.prototype
        const scanner = IRLScannerViewController.standardCameraViewWithDelegate(delegate)
        scanner.presentViewControllerAnimatedCompletion(scanner, true, null);
    }


    public destroyNativeView() {

    }
}

标签: nativescriptnativescript-plugin

解决方案


推荐阅读