2

I am implementing an application which is used to draw images and text.User can create page and draw in that and save that page in document directory of application. But i am not able to figure out how to restore all the views he had added to the pages when user reopens the same document to edit it.

Prerna chavan
  • 3,179
  • 7
  • 35
  • 77

3 Answers3

3

you could serialize your UIView means you can encoded and decoded your view object because UIVIew implement the NSCoding protocols ..

Check out the below SO link for encoded and decoded your UIView object

How to serialize a UIView?

You could do the modification and also maintain the version easily.

Community
  • 1
  • 1
Jhaliya - Praveen Sharma
  • 31,697
  • 9
  • 72
  • 76
1

You must have a file or something like that to store your page. For example for your each images you need to save its frame and its image path for restoring it. And for each texts which user typed on the page you must save its frame again and its text of textview or textfield. And for all, you should save index of that layer as a closing to front or not!

I hope it be useful for you!

Hamed Rajabi Varamini
  • 3,439
  • 3
  • 24
  • 38
  • Thanks it was very helpfull. It is ok for image views and textviews but how can i store the free hand drawing using touches. – Prerna chavan Nov 23 '11 at 05:39
  • It depends on how you draw a free hand drawing?! If you compute a curve as a smooth line, you need to save its formula. But if you save them as a some points, so just save pixels. – Hamed Rajabi Varamini Nov 23 '11 at 05:43
0

Try to convert that to image like this : Create Image

After that you can save and load as a normal image.

Hope it will help ^^

Alex Moskalev
  • 607
  • 7
  • 15
  • But after i restore it as an image i will not be able to edit it. It consists of textViews. These textviews will not be able to edit if i create a image of that view. – Prerna chavan Nov 23 '11 at 05:33