I have a TableViewController which presents (push) a ViewController (ScannerViewController) with this code: Bar Code Scanner
There is the following method:
func captureOutput(_ captureOutput: AVCaptureOutput!, didOutputMetadataObjects metadataObjects: [Any]!, from connection: AVCaptureConnection!) {
captureSession.stopRunning()
if let metadataObject = metadataObjects.first {
let readableObject = metadataObject as! AVMetadataMachineReadableCodeObject;
AudioServicesPlaySystemSound(SystemSoundID(kSystemSoundID_Vibrate))
found(code: readableObject.stringValue);
}
dismiss(animated: true)
}
Instead of dismiss(animated: true) I'd like to trigger a seque. The method in the TableViewController is:
@IBAction func unwindWithSelectedCode(segue: UIStoryboardSegue) {
if let scannerViewController = segue.source as? ScannerViewController,
let selectedCode = scannerViewController.code {
myCode = selectedCode
}
}
Normally I have a button which I connect to ViewControllers Exit sign on the top of the VC in the storyboard and call the method above. But I have no button. So how can I call the seque method programmatically without a button?
try this
self.performSegue(withIdentifier: "unwindSegueIdentifier", sender: self)
replace unwindSegueIdentifier
with your identifier
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.