Search code examples
iosswiftuiimageviewunwind-segue

Get signature(YPDrawSignatureView) to display using an unwind segue


I'm trying to display a user's signature on another ViewController using an unwind segue. However when I press save (which I set to my Unwind segue) the UIImageView does not display the signature I took. I'm using YPDrawSignatureView to capture the signature and the .getSignature method in it

here's the get signature func (found in my SignatureViewController) :

var signatureimage = UIImage()
func getSignature() {
    signatureimage = self.Signature.getSignature()
}

and here's my unwind segue (found in another ViewController) :

@IBOutlet var signature: UIImageView!
@IBAction func unwindFromSignature(sender: UIStoryboardSegue) {
    if let sourceViewController = sender.sourceViewController as? SignatureView {
        sourceViewController.getSignature()
        signature = UIImageView(image: sourceViewController.signatureimage)
        signature.sizeToFit()
    }
}

as you can probably see, my final outlet is called "signature" and is an UIImageView.


Solution

  • You're creating a new image view when you do

    signature = UIImageView(image: sourceViewController.signatureImage)
    

    You want to set the image on your already existing image view

    signature.image = sourceViewController.signatureImage