jharwig / PPSSignatureView

iOS Signature Capture Demo
MIT License
1.04k stars 234 forks source link

Needs a method to restore a signature #11

Open jdmuys opened 10 years ago

jdmuys commented 10 years ago

If you want to persist a signature across application launches, you need to save it first, using signatureImage. But you also need to restore a previously saved image back to the PPSSignatureView. Any idea how to do that?

aschepis commented 10 years ago

@jdmuys I don't think you'd want to do it that way. You want want to save/restore the raw data used to generate the image (such as the vertices and dots stored in the PPSSignatureView.) Unfortunately, at the present time the code doesn't store enough historical state as the user is signing to rebuild it. Things like pen thickness are not saved per sample.

It wouldn't be incredibly hard to add this sort of saving. The first way that comes to mind would be to simply keep an array of state objects/structs for each sample that is taken. Then you would want to refactor the tap and pan methods so that they were much simpler and just built one of these events, appended it to the array and then called another method with the smarts (you could call them onDot and onDraw for instance.) This would allow you to replay a signature by iterating the array of saved samples and calling those functions.

Swinny1989 commented 8 years ago

Have you done anything to implement this functionality? It's something that I really need to use in my current project