Store a signature to MySql from iPad. part 1. The Signature

Store a signature to MySql from iPad. part 1. The Signature

This set of posts describes my efforts to capture a user signature on an iPad and save this as a BLOB in MySQL.

Now, there’s no way to talk directly to MySQL from the iPad so once the signature image is captured it must be packaged up and transmitted to my web service which will store it using a MySQL Stored procedure. The new status of the visit that this signature relates to as well as the visit ID number also have to be transmitted.

Part 1.

Capture the signature on the iPad

No point in re-inventing the wheel. I use the excellent library YPDrawSignatureView which can easily be added to your view controller

screen-shot-2017-04-19-at-09-26-07

You must add an outlet and add the YP Signature delegate capability to your class

class SignaturePage: UIViewController, YPSignatureDelegate {

     @IBOutlet weak var signatureView: YPDrawSignatureView!

 ….

It’s also necessary to add the following to the viewDidLoad function:

override func viewDidLoad() {
        super.viewDidLoad()
        signatureView.delegate = self 
    }

So far the signature box doesn’t look like much. I will do something about the lack of style in this application in a later post.

I’ve added a button (the text under the signature box) which just triggers the function saveSignature.

In the example provided on the YPSaveSignature GIT the captured signature is added to the photoroll on the iPad. I don’t want that. I need to capture the image data and send it to my web service. The image data can be stored in memory as a PNG like this.

let image_data = UIImagePNGRepresentation(signatureImage)

Next time packaging up the image with some other parameters and transmitting to the web service.

 

Leave a Reply

Your email address will not be published. Required fields are marked *

For security, use of Google's reCAPTCHA service is required which is subject to the Google Privacy Policy and Terms of Use.