Comments (9)
Hi,
can you put a screenshot please?
from qrcodereader.swift.
from qrcodereader.swift.
Only if i scanned a ticket i get thus
from qrcodereader.swift.
I just pushed a "fix", I don't know if it'll fix your problem. I need to see a bit of your code to know whether the problem comes from the lib.
from qrcodereader.swift.
didn't fixed it for me
Here is my Scanner code
class ScannerViewController: UIViewController, QRCodeReaderViewControllerDelegate {
var scannedtickets = [NSManagedObject]()
var alert = SCLAlertView()
let managedObjectContext = (UIApplication.sharedApplication().delegate as! AppDelegate).managedObjectContext
var frcontroller: NSFetchedResultsController = NSFetchedResultsController()
struct status : JSONJoy {
var error: Bool?
var message: String?
init() {
}
init(_ decoder: JSONDecoder) {
error = decoder["error"].bool
message = decoder["message"].string
}
}
private func contentView(text: String) -> UIView {
let view = UIView(frame: CGRect(x: 0, y: 50, width: 375, height: 64))
view.autoresizingMask = [.FlexibleWidth, .FlexibleHeight]
let label = UILabel(frame: view.bounds)
label.frame.origin.x = 10
label.frame.origin.y = 10
label.frame.size.width -= label.frame.origin.x
label.frame.size.height -= label.frame.origin.y
label.autoresizingMask = [.FlexibleWidth, .FlexibleHeight]
label.text = text
label.numberOfLines = 2
label.textColor = UIColor.whiteColor()
view.addSubview(label)
return view
}
lazy var reader = QRCodeReaderViewController(metadataObjectTypes: [AVMetadataObjectTypeQRCode])
@IBAction func scanAction(sender: AnyObject) {
if QRCodeReader.supportsMetadataObjectTypes() {
reader.modalPresentationStyle = .FormSheet
reader.delegate = self
reader.completionBlock = { (result: String?) in
let evid = NSUserDefaults.standardUserDefaults().objectForKey("eventid")
let params = ["eventid": "\(evid!)", "qrcode":"\(result!)"]
print(result)
do {
let opt = try HTTP.POST(url, parameters: params)
opt.start { response in
//do things...
print(response.description)
let json = JSON(data: response.data)
if json["error"] == true {
let mess = json["message"]
dispatch_async(dispatch_get_main_queue(),{
self.alert.showTitle(
"Ongeldige Ticket", // Title of view
subTitle: "\(mess)", // String of view
duration: 3.0, // Duration to show before closing automatically, default: 0.0
completeText: "Verder scannen", // Optional button value, default: ""
style: .Error,// Styles - see below.
colorStyle: 0xe74c3c,
colorTextButton: 0xFFFFFF
).setDismissBlock({ () -> Void in
self.reader.startScanning()
})
})
} else if json["error"] == false {
self.title = "Notification"
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, Int64(1 * Double(NSEC_PER_SEC))), dispatch_get_main_queue()) {
let access = json["access"]
if access == "granded" {
let mess = json["message"]
let qrid = json["ticket"]["id"].string!
let klantnaams = json["ticket"]["klant_naam"].string!
let ticketnaams = json["ticket"]["ticketnaam"].string!
let geldigs = json["ticket"]["geldig"].string!
let ticket_ids = json["ticket"]["ticket_id"].string!
let eventids = json["ticket"]["eventid"].string!
let emails = json["ticket"]["email"].string!
let qrcodes = json["ticket"]["qrcontent"].string!
self.createTickets(qrid,klantnaam: klantnaams,ticketnaam: ticketnaams,geldig: geldigs,ticket_id: ticket_ids,eventid: eventids,email: emails,qrcode: qrcodes)
self.alert.showTitle(
"Ticket Goedgekeurd", // Title of view
subTitle: "\(mess)", // String of view
duration: 3.0, // Duration to show before closing automatically, default: 0.0
completeText: "Verder scannen", // Optional button value, default: ""
style: .Success,// Styles - see below.
colorStyle: 0x2ecc71,
colorTextButton: 0xFFFFFF
).setDismissBlock({ () -> Void in
self.reader.startScanning()
})
NSNotificationCenter.defaultCenter().postNotificationName("Updater", object: nil, userInfo: nil)
} else if access == "denied" {
let mess = json["message"]
self.alert.showTitle(
"Ticket Afgekeurd", // Title of view
subTitle: "\(mess)", // String of view
duration: 3.0, // Duration to show before closing automatically, default: 0.0
completeText: "Verder scannen", // Optional button value, default: ""
style: .Error,// Styles - see below.
colorStyle: 0xe74c3c,
colorTextButton: 0xFFFFFF
).setDismissBlock({ () -> Void in
self.reader.startScanning()
})
}
}
/* self.savetickets("1",ticketnaam: "test",ticket_id: "2",event_id: "33",qrcontent: "32332-2-23",klant_naam:"sharlutci poeketi",geldig: "21-09-2016",email: "[email protected]") */
}
}
} catch let error {
print("got an error creating the request: \(error)")
}
}
presentViewController(reader, animated: true, completion: nil)
}
else {
let alert = UIAlertController(title: "Error", message: "QR Reader word niet ondersteund door uw apparaat", preferredStyle: .Alert)
alert.addAction(UIAlertAction(title: "OK", style: .Cancel, handler: nil))
presentViewController(alert, animated: true, completion: nil)
}
}
// MARK: - QRCodeReader Delegate Methods
func reader(reader: QRCodeReaderViewController, didScanResult result: String) {
self.dismissViewControllerAnimated(true, completion: { [unowned self] () -> Void in
let alert = UIAlertController(title: "QRCodeReader", message: result, preferredStyle: .Alert)
alert.addAction(UIAlertAction(title: "OK", style: .Cancel, handler: nil))
self.presentViewController(alert, animated: true, completion: nil)
})
}
func readerDidCancel(reader: QRCodeReaderViewController) {
self.dismissViewControllerAnimated(true, completion: nil)
}
from qrcodereader.swift.
I show nothing special with that. If you try with a very small project without all this boilerplate, is the problem occured?
from qrcodereader.swift.
i'll take a look
from qrcodereader.swift.
@tpcmedia777 It's been more than half a year here but the problem was with the
self.title = "Notification"
in one of your closures.
@yannickl I think we can close this issue.
from qrcodereader.swift.
Yes you've right @PabloLerma! I didn't see this line. Thank you!
from qrcodereader.swift.
Related Issues (20)
- How to get result in as NSDictionary. HOT 2
- I want to stop camera after validation of QR code HOT 2
- Use weakSelf.builder.readerView HOT 1
- xcode 11 beta issue
- QR Code Scanning issue for pod version 8.2.0 HOT 2
- QRCodeReader shows image of last scan on re-open
- build error UIApplication.shared is unavailable in app extension HOT 3
- Allow raw QRCode bytes
- Region of interest feature does not work for non-square aspect ratios(!) HOT 4
- CIFilter(name: "CIQRCodeGenerator") ĺ´Šćş HOT 7
- CIFilter(name: "CIQRCodeGenerator") Crash with iPhone XR (iOS 13.1.3)
- Exception: Array mutated while being enumerated HOT 3
- How can I make the front camera to run in the beginning as default option
- The QRcode identification area is inconsistent with the dashed box area
- Make QRCodeReaderViewController an open class to allow subclassing
- Crash in configureDefaultComponents on previewLayer
- Fatal Exception: NSInvalidArgumentException
- Reshape OverlayView to square
- Crash on metadataOutput.availableMetadataObjectTypes in QRCodeReader HOT 4
- Tnv
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
đ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. đđđ
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google â¤ď¸ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from qrcodereader.swift.