我有类firstViewController在这个函数产生的itemid访问常数从另一个视图控制器
func captureOutput(_ captureOutput: AVCaptureOutput!, didOutputMetadataObjects metadataObjects: [Any]!, from connection: AVCaptureConnection!) {
// Check if the metadataObjects array is not nil and it contains at least one object.
if metadataObjects == nil || metadataObjects.count == 0 {
qrCodeFrameView?.frame = CGRect.zero
messageLabel.text = "No QR/barcode is detected"
return
}
//Get metadata object
let metadataObj = metadataObjects[0] as! AVMetadataMachineReadableCodeObject
if supportedCodeTypes.contains(metadataObj.type) {
//if the found metadata is equal to the QR code metadata then update the status label's text and set the the bounds
let barCodeObject = videoPreviewLayer?.transformedMetadataObject(for: metadataObj)
qrCodeFrameView?.frame = barCodeObject!.bounds
if metadataObj.stringValue != nil {
messageLabel.text = metadataObj.stringValue
let itemID = metadataObj.stringValue
print(itemID)
}
}
}
我想打电话给ITEMID在其他的viewController称为secondViewController。如何从secondViewController中的firstViewController调用itemID?
谢谢,我正在做所有的编程。在FirstViewController中究竟应该声明代码,我似乎有这个问题让secondViewConttoller = SecondViewController() secondViewController.itemIdForSVC = self.itemID self.navigationController?.pushViewController(secondViewConttoller,animated:true) –
您应该添加这段代码从你想要去的下一个第二页开始,即onButtonTapped事件。 –