-2

I'm setting up a barcode reader app, got 3 tab bar item and one of them "SCAN" tab and another one of them is "WEBVIEW" tab. When user scan the barcode or qr, it's giving a string and going to webview's url. I want to send this string to url and open the webview tab. Can you help me with this problem ?

  if (metadataObjects.count > 0 && metadataObjects.first is AVMetadataMachineReadableCodeObject) {

        let scan = metadataObjects.first as! AVMetadataMachineReadableCodeObject

        let alertController = UIAlertController(title: "Barkod Tarandı", message: scan.stringValue, preferredStyle: .alert)



        alertController.addAction(UIAlertAction(title: "TAMAM", style: .default, handler:nil))



        present(alertController, animated: true, completion: nil)



        if(scan.stringValue != nil)
        {
            if let aString = URL(string: "" + ("http://www.truebilisim.com/myiphone/true/mymagazaplus/barkod.php?barkod=\(scan.stringValue)")) {
                webalani.loadRequest(URLRequest(url: aString))
            }
        }

    }
Refih Can
  • 64
  • 8

1 Answers1

0

Use the NSURL it must work.

webalani.loadRequest(NSURLRequest(URL: NSURL(string: "aString")!))

And make sure your this line must be NSURL too

if let aString = URL(string: "" + ("http://www.truebilisim.com/myiphone/true/mymagazaplus/barkod.php?barkod=\(scan.stringValue)")) {