I come here with a very very strange error.
I have 3 View controllers in my storyboard.
1) Main Page with list of products ViewController
2) Single Product Detail ProductViewController
3) Barcode scanner BarcodeViewController
In the MAIN and PRODUCT DETAIL ViewController
, i have a button saying "Scan Barcode" on top.
I first coded the button of "Scan Barcode
" in the ViewController
and segue it to the BarcodeViewController
. It works perfectly.
For the same Scan Button in ProductViewController
, i coded it differently.
I drag the button to EXIT. So that the ViewController
loads again and as soon as it is loaded i programmatically load the Barcode scanner.
It does not work.
There is no error, there is no crash, nothing. Even Prepare for segue function is called. It goes into the right block everywhere.
Just the BarcodeViewController
dont show up.
The code in ViewController
@IBAction func returned (segue: UIStoryboardSegue) {
NSLog("Returned Segue \(segue.identifier)")
if ( segue.identifier == "unwindToMainViewViaBarcode" )
{
dispatch_async(dispatch_get_main_queue(), {
self.performSegueWithIdentifier(self.segueIdentifierForBarcode, sender: nil)
});
}
}
override func prepareForSegue(segue: UIStoryboardSegue, sender: AnyObject?) {
NSLog("PrepareForSegue \(segue.identifier)")
if ( segue.identifier == segueIdentifierForBarcode )
{
// Reset barcode String
barcodeString = ""
// get reference for ViewController and set as a var
let destination = segue.destinationViewController as! BarcodeViewController
destination.mainView = self;
print("open barcode called")
}
}