Skip to content

Commit

Permalink
Merge pull request #5 from 66feetLLC/issue_4
Browse files Browse the repository at this point in the history
Patch for Issue #4 - Working with WKWebView
  • Loading branch information
bitjson committed Apr 4, 2016
2 parents 3a15f20 + 831639f commit 953c971
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion src/ios/QRScanner.swift
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import AVFoundation
@objc(QRScanner)
class QRScanner : CDVPlugin, AVCaptureMetadataOutputObjectsDelegate {

var cameraView: UIView = UIView(frame: CGRect(x: 0, y: 0, width: UIScreen.mainScreen().bounds.width, height: UIScreen.mainScreen().bounds.height))
var cameraView: UIView!
var captureSession:AVCaptureSession?
var captureVideoPreviewLayer:AVCaptureVideoPreviewLayer?
var metaOutput: AVCaptureMetadataOutput?
Expand Down Expand Up @@ -38,6 +38,12 @@ class QRScanner : CDVPlugin, AVCaptureMetadataOutputObjectsDelegate {
case torchUnavailable
}

override func pluginInitialize() {
super.pluginInitialize()
NSNotificationCenter.defaultCenter().addObserver(self, selector: #selector(pageDidLoad), name: CDVPageDidLoadNotification, object: nil)
self.cameraView = UIView(frame: CGRect(x: 0, y: 0, width: UIScreen.mainScreen().bounds.width, height: UIScreen.mainScreen().bounds.height))
}

func sendErrorCode(command: CDVInvokedUrlCommand, error: QRScannerError){
let pluginResult = CDVPluginResult(status: CDVCommandStatus_ERROR, messageAsInt: error.rawValue)
commandDelegate!.sendPluginResult(pluginResult, callbackId:command.callbackId)
Expand Down Expand Up @@ -192,6 +198,11 @@ class QRScanner : CDVPlugin, AVCaptureMetadataOutputObjectsDelegate {
}
}

func pageDidLoad() {
self.webView?.opaque = false
self.webView?.backgroundColor = UIColor.clearColor()
}

// ---- BEGIN EXTERNAL API ----

func prepare(command: CDVInvokedUrlCommand){
Expand Down

0 comments on commit 953c971

Please sign in to comment.