I want to implement freeform drawing in my PDF reader app. I saw a tutorial which uses UIImageView as the view where the drawings are rendered. I tried this and it works well, except when I try to save the drawing. Sometimes it prevents me from going from one page to another unless I tap the edges twice, other times the transition is smooth.
So what is the best way to implement this functionality?
–ADDITIONAL INFO–
To save the drawing, what I do is save it as an image using UIImagePNGRepresentation to save it in the directory. The saved image’s file name is based on the bookId and page number of the document (e.g. 121-5.png)
Now to load the drawing, a function is called which checks if an image is present based on the book’s id and page number. So if the book has and ID of 121 and I am on page 5, the function will then load the image “121-5.png”.
This is just a guess (and its too late where I am to expand much on it), but if you’re trying to do the saving part in the most obvious way, probably you’re stalling the main (UI) thread. Its possible you’re not, so sorry if its presumptuous. If so, this will cause the whole interface to stall out until the image has been rendered, compressed, and saved.
Two easy-ish methods to fix that:
NSOperationis a start. Here’s a random tutorial)